html_executor

Crates.iohtml_executor
lib.rshtml_executor
version0.1.1
sourcesrc
created_at2024-11-14 21:34:32.299502
updated_at2024-11-14 21:34:32.299502
descriptionExecute JS rendered HTML from a request
homepage
repositoryhttps://github.com/0xlunar/html_executor
max_upload_size
id1448364
size43,885
(0xlunar)

documentation

README

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}");
}
Commit count: 5

cargo fmt