Advertisement
dereksir

Untitled

May 15th, 2024
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.52 KB | None | 0 0
  1. use select::document::Document;
  2. use select::predicate::*;
  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.     // parse the response text into a Document
  10.     let document = Document::from(resp.as_str());
  11.  
  12.     // find the price element using its HTML tag and class
  13.     if let Some(price_node) = document.find(Name("p").and(Class("price"))).next() {
  14.         println!("Price: {}", price_node.text());
  15.     }
  16.  
  17.     Ok(())
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement