pub fn select_attr(
doc: &Document,
selector: &str,
attr: &str,
) -> QueryResult<Vec<Option<String>>>Expand description
Extracts attribute values from all elements matching a CSS selector.
Returns Some(value) if the attribute exists, None if it doesn’t.
Empty vector if no elements match.
§Errors
Returns [QueryError::InvalidSelector] if the selector syntax is invalid.
§Examples
use scrape_core::{Soup, query::select_attr};
let soup = Soup::parse("<a href='/a'>A</a><a href='/b'>B</a>");
let hrefs = select_attr(soup.document(), "a", "href").unwrap();
assert_eq!(hrefs, vec![Some("/a".to_string()), Some("/b".to_string())]);