Skip to content

Commit

Permalink
Fix keyword.id & authorization for searchapi
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastjanPrachovskij committed Nov 9, 2023
1 parent 9b6453c commit 9ebecc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scrapers/services/searchapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const searchapi:ScraperSettings = {
headers: (keyword, settings) => {
return {
'Content-Type': 'application/json',
'X-API-Key': settings.scaping_api,
'Authorization': `Bearer ${settings.scaping_api}`,
};
},
scrapeURL: (keyword, settings) => {
return `https://www.searchapi.io/api/v1/search?engine=google&q=${encodeURI(keyword.keyword)}&num=100&gl=${keyword.country}&device=${keyword.device}&api_key=${settings.scaping_api}`;
return `https://www.searchapi.io/api/v1/search?engine=google&q=${encodeURI(keyword.keyword)}&num=100&gl=${keyword.country}&device=${keyword.device}`;
},
resultObjectKey: 'organic_results',
serpExtractor: (content) => {
Expand Down
2 changes: 1 addition & 1 deletion utils/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const refreshAndUpdateKeywords = async (rawkeyword:Keyword[], settings:SettingsT
const refreshedResults = await refreshParallel(keywords, settings);
if (refreshedResults.length > 0) {
for (const keyword of rawkeyword) {
const refreshedkeywordData = refreshedResults.find((k) => k && k.ID === keyword.id);
const refreshedkeywordData = refreshedResults.find((k) => k && k.ID === keyword.ID);
if (refreshedkeywordData) {
const updatedkeyword = await updateKeywordPosition(keyword, refreshedkeywordData, settings);
updatedKeywords.push(updatedkeyword);
Expand Down

0 comments on commit 9ebecc6

Please sign in to comment.