Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[tokio::main]
- async fn main() -> Result<(), Box<dyn std::error::Error>> {
- // make GET request to target URL and retrieve response
- //...
- // create an HTML parser
- let fragment = scraper::Html::parse_fragment(&resp);
- // define CSS selector for the price element
- let price_selector = scraper::Selector::parse(".price").unwrap();
- // extract the price using the CSS selector
- let price_element = fragment.select(&price_selector).next().unwrap();
- let price = price_element.text().collect::<String>();
- println!("Price: {}", price);
- Ok(())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement