1 unstable release
new 0.1.1 | Nov 14, 2024 |
---|
#1660 in Web programming
102 downloads per month
16KB
67 lines
html_executor
Execute Javascript from a given HTML page
Supported request libraries
Examples
Reqwest
use html_executor::HTMLRendererExt;
#[tokio::main]
async fn main() {
let response = reqwest::get("https://example.com/").await.unwrap();
let rendered = response.render(None, None).await.unwrap();
println!("{rendered}");
}
Rquest
use html_executor::HTMLRendererExt;
#[tokio::main]
async fn main() {
let response = rquest::get("https://example.com/").await.unwrap();
let rendered = response.render(None, None).await.unwrap();
println!("{rendered}");
}
Non-Request Format
use html_executor::{render_html, RenderOptions};
#[tokio::main]
async fn main() {
let response = reqwest::get("https://example.com/").await.unwrap();
let url = response.url();
let html = response.text().await.unwrap();
let options = RenderOptions {
html: html.as_str(),
url: url.as_str(),
chromedriver_url: None,
output_delay: None,
};
let rendered = render_html(options).await.unwrap();
println!("{rendered}");
}
Dependencies
~11–24MB
~348K SLoC