Advertisement
dereksir

Untitled

May 15th, 2024
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.68 KB | None | 0 0
  1. #[tokio::main]
  2. async fn main() -> Result<(), Box<dyn std::error::Error>> {
  3.     // make GET request to target URL and retrieve response
  4.     //...
  5.  
  6.     // convert HTML to Markdown
  7.     let md = html2md::parse_html(&resp);
  8.  
  9.     // create a Markdown parser
  10.     let parser = pulldown_cmark::Parser::new(&md);
  11.  
  12.     // iterate over the events in the parser
  13.     for event in parser {
  14.         match event {
  15.             pulldown_cmark::Event::Text(text) => {
  16.                 // check if the text contains the price
  17.                 if text.contains("$") {
  18.                     println!("Price: {}", text);
  19.                 }
  20.             },
  21.             _ => {},
  22.         }
  23.     }
  24.  
  25.     Ok(())
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement