fix google featured snippets sometimes matching the wrong link

This commit is contained in:
mat 2024-06-30 17:32:52 -05:00
parent f82e4f8870
commit f98e3c68f0

View File

@ -54,7 +54,7 @@ pub fn parse_response(body: &str) -> eyre::Result<EngineResponse> {
.featured_snippet_title("h3") .featured_snippet_title("h3")
.featured_snippet_href(QueryMethod::Manual(Box::new(|el: &ElementRef| { .featured_snippet_href(QueryMethod::Manual(Box::new(|el: &ElementRef| {
let url = el let url = el
.select(&Selector::parse("a").unwrap()) .select(&Selector::parse("div[lang] a").unwrap())
.next() .next()
.and_then(|n| n.value().attr("href")) .and_then(|n| n.value().attr("href"))
.unwrap_or_default(); .unwrap_or_default();