From c6cef00f63a9a3d58002bcf6fc98cfc157f9d51c Mon Sep 17 00:00:00 2001 From: Artemy Date: Sun, 17 Sep 2023 11:25:17 +0300 Subject: [PATCH] feat: fix google parsing there's no more navigation --- src/handlers/google.ts | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/handlers/google.ts b/src/handlers/google.ts index 06568cc..6783d8a 100644 --- a/src/handlers/google.ts +++ b/src/handlers/google.ts @@ -3,17 +3,17 @@ import { IHandlerOutput } from "./handler.interface"; import { EngineParseError } from "../errors/main"; export default async function google( - input: HandlerInput, + input: HandlerInput ): Promise { const window = input.parseDom().window; const googleAnchors = [ - ...window.document.querySelectorAll("a[jsname=ACyKwe]"), + ...window.document.querySelectorAll("a[jsname=UWckNb]"), ] as HTMLAnchorElement[]; if (!googleAnchors) { throw new EngineParseError( - "Failed to find anchors in search result [google]", + "Failed to find anchors in search result [google]" ); } @@ -43,31 +43,9 @@ export default async function google( }); const search = window.document.getElementById( - "APjFqb", + "APjFqb" ) as HTMLTextAreaElement; - const navLinks = [ - ...window.document.querySelectorAll( - "table[class=AaVjTc] > tbody > tr > td > a", - ), - ].map((l) => { - const link = l as HTMLAnchorElement; - return `${link.innerHTML}`; - }); - - const currPage = - (window.document.querySelector(".YyVfkd") as HTMLTableCellElement) - ?.cellIndex || 0; - - const pageTd = `${currPage}`; - - if (currPage === 1) navLinks.splice(currPage - 1, 0, pageTd); - else if (currPage !== 0) navLinks.splice(currPage, 0, pageTd); - - const navigation = ` - ${navLinks.join("")} -
`; - const searchForm = `
@@ -76,7 +54,7 @@ export default async function google( `; return { - content: `${searchForm}${content.join("")}${navigation}`, + content: `${searchForm}${content.join("")}`, textContent: textContent.join("\n"), }; }