forked from towfiqi/serpbear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary spacing Fix keyword.id & authorization for searchapi
- Loading branch information
1 parent
f164b28
commit 8a35e35
Showing
7 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const searchapi:ScraperSettings = { | ||
id: 'searchapi', | ||
name: 'SearchApi.io', | ||
website: 'searchapi.io', | ||
headers: (keyword, settings) => { | ||
return { | ||
'Content-Type': 'application/json', | ||
'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}`; | ||
}, | ||
resultObjectKey: 'organic_results', | ||
serpExtractor: (content) => { | ||
const extractedResult = []; | ||
const results: SearchApiResult[] = (typeof content === 'string') ? JSON.parse(content) : content as SearchApiResult[]; | ||
|
||
for (const { link, title, position } of results) { | ||
if (title && link) { | ||
extractedResult.push({ | ||
title, | ||
url: link, | ||
position, | ||
}); | ||
} | ||
} | ||
return extractedResult; | ||
}, | ||
}; | ||
|
||
interface SearchApiResult { | ||
title: string, | ||
link: string, | ||
position: number, | ||
} | ||
|
||
export default searchapi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters