Find a html element with id with scraper

how can I find a element with a special id in HTML with scraper?

<tr id="12345678">


let isin_selector = scraper::Selector::parse("tr#12345678").unwrap();  
let v:Vec<_>;
if v.len()>0

Since 12345678 starts with a digit, it is not a valid CSS identifier, and it cannot be used in a CSS ID selector. Therefore, you must use an attribute selector with the id attribute, e.g., Selector::parse("tr[id='12345678']"). Alternatively, you can filter the list of results based on the id attribute:

let tr_selector = Selector::parse("tr").unwrap();
let element = document
    .find(|element| element.value().attr("id") == Some("12345678"));
if let Some(element) = element {
    println!("found element: {}", element.html());
} else {
    println!("did not find element");

Thank you. Both versions work.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.