Advertisement
dereksir

Untitled

May 15th, 2024
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.52 KB | None | 0 0
  1. use kuchiki::traits::*;
  2. use kuchiki::parse_html;
  3.  
  4. #[tokio::main]
  5. async fn main() -> Result<(), Box<dyn std::error::Error>> {
  6.     // make GET request to target URL and retrieve response
  7.     //...
  8.  
  9.     let document = parse_html().one(resp);
  10.  
  11.     // select the "p" element with class "price"
  12.     if let Some(price_node) = document.select_first("p.price").ok() {
  13.         let price = price_node.text_contents();
  14.         println!("Price: {}", price);
  15.     } else {
  16.         println!("Price not found");
  17.     }
  18.  
  19.     Ok(())
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement