mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
feat: Integrates Space Serp.
This commit is contained in:
parent
cace34f39a
commit
0538a8c016
@ -151,7 +151,7 @@ const Settings = ({ closeSettings }:SettingsProps) => {
|
||||
minWidth={270}
|
||||
/>
|
||||
</div>
|
||||
{['scrapingant', 'scrapingrobot', 'serply', 'serpapi'].includes(settings.scraper_type) && (
|
||||
{['scrapingant', 'scrapingrobot', 'serply', 'serpapi', 'spaceSerp'].includes(settings.scraper_type) && (
|
||||
<div className="settings__section__input mr-3">
|
||||
<label className={labelStyle}>Scraper API Key or Token</label>
|
||||
<input
|
||||
|
@ -2,6 +2,7 @@ import scrapingAnt from './services/scrapingant';
|
||||
import scrapingRobot from './services/scrapingrobot';
|
||||
import serpapi from './services/serpapi';
|
||||
import serply from './services/serply';
|
||||
import spaceserp from './services/spaceserp';
|
||||
import proxy from './services/proxy';
|
||||
|
||||
export default [
|
||||
@ -9,5 +10,6 @@ export default [
|
||||
scrapingAnt,
|
||||
serpapi,
|
||||
serply,
|
||||
spaceserp,
|
||||
proxy,
|
||||
];
|
||||
|
34
scrapers/services/spaceserp.ts
Normal file
34
scrapers/services/spaceserp.ts
Normal file
@ -0,0 +1,34 @@
|
||||
interface SpaceSerpResult {
|
||||
title: string,
|
||||
link: string,
|
||||
domain: string,
|
||||
position: number
|
||||
}
|
||||
|
||||
const spaceSerp:ScraperSettings = {
|
||||
id: 'spaceSerp',
|
||||
name: 'Space Serp',
|
||||
website: 'spaceserp.com',
|
||||
scrapeURL: (keyword, settings, countryData) => {
|
||||
const country = keyword.country || 'US';
|
||||
const lang = countryData[country][2];
|
||||
return `https://api.spaceserp.com/google/search?apiKey=${settings.scaping_api}&q=${encodeURI(keyword.keyword)}&pageSize=100&gl=${country}&hl=${lang}${keyword.device === 'mobile' ? '&device=mobile' : ''}&resultBlocks=`;
|
||||
},
|
||||
resultObjectKey: 'organic_results',
|
||||
serpExtractor: (content) => {
|
||||
const extractedResult = [];
|
||||
const results: SpaceSerpResult[] = (typeof content === 'string') ? JSON.parse(content) : content as SpaceSerpResult[];
|
||||
for (const result of results) {
|
||||
if (result.title && result.link) {
|
||||
extractedResult.push({
|
||||
title: result.title,
|
||||
url: result.link,
|
||||
position: result.position,
|
||||
});
|
||||
}
|
||||
}
|
||||
return extractedResult;
|
||||
},
|
||||
};
|
||||
|
||||
export default spaceSerp;
|
Loading…
Reference in New Issue
Block a user