From 9feff13f18a4d72203dde694a147831f990b37fb Mon Sep 17 00:00:00 2001 From: towfiqi Date: Fri, 3 Nov 2023 21:44:23 +0600 Subject: [PATCH] fix: Fxies special character keyword scrape issue. closes #113 #122 --- scrapers/services/scrapingant.ts | 3 ++- scrapers/services/scrapingrobot.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scrapers/services/scrapingant.ts b/scrapers/services/scrapingant.ts index 6074b94..0edfbaf 100644 --- a/scrapers/services/scrapingant.ts +++ b/scrapers/services/scrapingant.ts @@ -11,7 +11,8 @@ const scrapingAnt:ScraperSettings = { const scraperCountries = ['AE', 'BR', 'CN', 'DE', 'ES', 'FR', 'GB', 'HK', 'PL', 'IN', 'IT', 'IL', 'JP', 'NL', 'RU', 'SA', 'US', 'CZ']; const country = scraperCountries.includes(keyword.country.toUpperCase()) ? keyword.country : 'US'; const lang = countryData[country][2]; - return `https://api.scrapingant.com/v2/extended?url=https%3A%2F%2Fwww.google.com%2Fsearch%3Fnum%3D100%26hl%3D${lang}%26q%3D${encodeURI(keyword.keyword)}&x-api-key=${settings.scaping_api}&proxy_country=${country}&browser=false`; + const url = encodeURI(`https://www.google.com/search?num=100&hl=${lang}&q=${keyword.keyword}`); + return `https://api.scrapingant.com/v2/extended?url=${url}&x-api-key=${settings.scaping_api}&proxy_country=${country}&browser=false`; }, resultObjectKey: 'result', }; diff --git a/scrapers/services/scrapingrobot.ts b/scrapers/services/scrapingrobot.ts index 4795abd..6541347 100644 --- a/scrapers/services/scrapingrobot.ts +++ b/scrapers/services/scrapingrobot.ts @@ -4,8 +4,10 @@ const scrapingRobot:ScraperSettings = { website: 'scrapingrobot.com', scrapeURL: (keyword, settings, countryData) => { const country = keyword.country || 'US'; + const device = keyword.device === 'mobile' ? '&mobile=true' : ''; const lang = countryData[country][2]; - return `https://api.scrapingrobot.com/?token=${settings.scaping_api}&proxyCountry=${country}&render=false${keyword.device === 'mobile' ? '&mobile=true' : ''}&url=https%3A%2F%2Fwww.google.com%2Fsearch%3Fnum%3D100%26hl%3D${lang}%26q%3D${encodeURI(keyword.keyword)}`; + const url = encodeURI(`https://www.google.com/search?num=100&hl=${lang}&q=${keyword.keyword}`); + return `https://api.scrapingrobot.com/?token=${settings.scaping_api}&proxyCountry=${country}&render=false${device}&url=${url}`; }, resultObjectKey: 'result', };