Gathering detailed insights and metrics for serp-parser-v1
Gathering detailed insights and metrics for serp-parser-v1
npm install serp-parser-v1
Typescript
Module System
Node Version
NPM Version
67.6
Supply Chain
96.8
Quality
80
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
100%
6
Compared to previous week
Last month
300%
24
Compared to previous month
Last year
0%
632
Compared to previous year
This is a simple Google SERP (Search Engine Results Page) parser built with Node.js , Typescript and Cheerio. It extracts organic search results, paid ads, and Product Listing Ads (PLA) from Google search results HTML content.
GoogleSERP accepts html content as input and provides the parsed result as output.
https://github.com/ScraperPlatform/serp-parser.git
2.Install Dependencies
npm install
Create an instance of GoogleSERP with the HTML content of a Google search results page:
import { GoogleSERP } from 'google.ts'
const googleSERP = new GoogleSERP(htmlContent);
For mobile usage import the GoogleMobileSERP class from gogole-mobile.ts.
import { GoogleMobileSERP } from 'google-mobile.ts'
const googleMobileSERP = new GoogleSERP(htmlContent);
console.log('Keyword:', googleMobileSERP.serp.keyword);
console.log('PLA Results:', googleMobileSERP.serp.pla);
console.log('Organic Results:', googleMobileSERP.serp.organic);
console.log('Paid Results:', googleMobileSERP.serp.paid);
It will return interface like this .
interface StructuredData {
page: number;
results: {
pla?: Pla[];
paid?: Paid[];
organic?: Organic[];
};
}
For running tests run
npm test
This will run the file GoogleSERP.test.ts present in tests/google directory.This will test the app with taking sample.html as input , also present in the same directory .
If you want to test the application with custom html content you can create a file src directory for testing and a sample html file for testing . 1- Eg. Create sampleTest.ts in src directory and also create sample.html file in same directory and put any html content you want to test.
Paste this code in sampleTest.ts
import * as fs from 'fs';
import { GoogleSERP } from './google';
// Read the contents of sample.html
const htmlContent = fs.readFileSync('sample.html', 'utf8');
// Create an instance of GoogleSERP with the HTML content
const googleSERP = new GoogleSERP(htmlContent);
2- Change directory in to src and run
npx ts-node sampleTest.ts
3-You can check the output in the terminal .
For testing mobile results replicate the exact process . Paste this in sampleTest.ts
import * as fs from 'fs';
import { GoogleMobileSERP } from './google-mobile';
// Read the contents of sample.html
const htmlContent = fs.readFileSync('sample.html', 'utf8');
// Create an instance of GoogleMobileSERP with the HTML content
const googleSERP = new GoogleMobileSERP(htmlContent);
No vulnerabilities found.
No security vulnerabilities found.