Crates.io | html_executor |
lib.rs | html_executor |
version | 0.1.1 |
source | src |
created_at | 2024-11-14 21:34:32.299502 |
updated_at | 2024-11-14 21:34:32.299502 |
description | Execute JS rendered HTML from a request |
homepage | |
repository | https://github.com/0xlunar/html_executor |
max_upload_size | |
id | 1448364 |
size | 43,885 |
Execute Javascript from a given HTML page
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}");
}