fix: google name parsing
This commit is contained in:
parent
08a89190ed
commit
82a7fb96e6
@ -8,13 +8,13 @@ export default async function google(
|
||||
const googleAnchors = [
|
||||
...window.document.querySelectorAll("a[jsname=ACyKwe]"),
|
||||
] as HTMLAnchorElement[];
|
||||
const googleNames = [...window.document.querySelectorAll(".VuuXrf")];
|
||||
|
||||
const results = googleAnchors
|
||||
.map((a: HTMLAnchorElement, i: number): GoogleProps => {
|
||||
.map((a: HTMLAnchorElement): GoogleProps => {
|
||||
const parsedHref = new URL(new URL(a.href).searchParams.get("url")!);
|
||||
return {
|
||||
href: a.href!,
|
||||
siteName: googleNames[i].textContent!,
|
||||
siteName: parsedHref.hostname,
|
||||
heading: a.childNodes[1]?.textContent,
|
||||
};
|
||||
})
|
||||
@ -26,12 +26,6 @@ export default async function google(
|
||||
);
|
||||
}
|
||||
|
||||
if (!googleNames) {
|
||||
throw new EngineParseError(
|
||||
"Failed to find names in search result [google]"
|
||||
);
|
||||
}
|
||||
|
||||
const convertToFormat = (result: GoogleProps, isHtml: boolean) => {
|
||||
return isHtml
|
||||
? `<p><a href="${result.href}">${result.siteName} - ${result.heading}</p>`
|
||||
|
Loading…
x
Reference in New Issue
Block a user