This commit is contained in:
Yanlong Wang 2025-05-08 12:28:15 +08:00
parent bf84c993e2
commit 6c0aff4cc9
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -193,6 +193,9 @@ export class GoogleSERP extends AsyncService {
this.nativeIPBlocked(); this.nativeIPBlocked();
} }
this.contextPool.destroy(ctx); this.contextPool.destroy(ctx);
throw new ServiceBadAttemptError({
message: 'Google returned an error page. This may happen due to various reasons, including rate limiting or other issues.',
});
} }
if (opts && sideLoaded.sideLoadOpts) { if (opts && sideLoaded.sideLoadOpts) {
@ -217,6 +220,9 @@ export class GoogleSERP extends AsyncService {
const jsdom = this.jsDomControl.linkedom.parseHTML(html, { location: { href: origHref } }); const jsdom = this.jsDomControl.linkedom.parseHTML(html, { location: { href: origHref } });
try { try {
const r = runGetWebSearchResultsScript(createContext(jsdom)); const r = runGetWebSearchResultsScript(createContext(jsdom));
if (!Array.isArray(r)) {
throw new Error('Failed to parse response as SERP results');
}
return r; return r;
} catch (err) { } catch (err) {