causal-agent / scraper

HTML parsing and querying with CSS selectors
https://docs.rs/scraper
ISC License
1.79k stars 98 forks source link

same element? #138

Closed asyncins closed 8 months ago

asyncins commented 11 months ago

element_1 is <div>causal-agent</div>

element_2 is <p>scraper</p>

element_3 is <div>causal-agent</div>

we need this

if same(element_1, element_3){
  println!("true")
}else{
  println!("false")
}

How to ???

adamreichold commented 11 months ago

Defining what "same" means is usually specific to a use case. In the example you presented, a helper function which checks that element.value().name() and element.text() (possibly after trimming) match might be sufficient.

asyncins commented 11 months ago

Defining what "same" means is usually specific to a use case. In the example you presented, a helper function which checks that element.value().name() and element.text() (possibly after trimming) match might be sufficient.

the "same" means they are the same block of memory,not text, not name, not index, not tag

adamreichold commented 11 months ago

Then compare pointers std::ptr::eq(&element_1, &element_3).