fix another edge case with google featured snippets

This commit is contained in:
mat 2024-09-07 17:52:34 +00:00
parent f9c6602cc1
commit fb168fcfd7

View File

@ -53,10 +53,10 @@ pub fn parse_response(body: &str) -> eyre::Result<EngineResponse> {
Ok(description) Ok(description)
}))) })))
.featured_snippet_title(".g > div[lang] a h3") .featured_snippet_title(".g > div[lang] a h3, div[lang] > div[style='position:relative'] a 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(".g > div[lang] a:has(h3)").unwrap()) .select(&Selector::parse(".g > div[lang] a:has(h3), div[lang] > div[style='position:relative'] a:has(h3)").unwrap())
.next() .next()
.and_then(|n| n.value().attr("href")) .and_then(|n| n.value().attr("href"))
.unwrap_or_default(); .unwrap_or_default();