Giter Site home page Giter Site logo

utkarsh914 / serp-extended Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 569 KB

This npm module allows to execute search on Google with or without proxies. It provides different options for scraping the google results (either the list of the referenced sites or the number of results)

Home Page: https://www.npmjs.com/package/serp-extended

License: MIT License

JavaScript 100.00%
serp google scraper googlescraper scrapegoogle seo scrape serps

serp-extended's Introduction

serp-extended

This module is an extention to 'serp' module. It adds an option to exclude whichever websites you want from your search results. It allows to execute search on Google with or without proxies. It provides different options for scraping the google results (either the list of the referenced sites or the number of results).

Installation

$ npm install serp-extended

Simple usage

const serp = require("serp-extended");

var options = {
  host : "google.be",
  ignore: ['youtube.com', 'twitter.com'],
  qs : {
    q : "test",
    filter : 0,
    pws : 0,
    nfpr: 1
  },
  num : 10
};

const links = await serp.search(options);

Understanding the options structure :

  • For google.com, the param host is not necessary.
  • ignore contains an array of websites you want to exclude from your search results
  • qs can contain the usual Google search parameters : https://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters.
  • options.qs.q is the keyword
  • nfpr for exclusion of results from an auto-corrected query: 1 is disabled (default is 0)
  • num is the number of desired results (defaut is 10).
  • The options object can also contain all request options like http headers, ... . SERP is using the request module : https://github.com/request/request
  • The user agent is not mandatory. Default value will be : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'

With proxy

You can add the proxy reference in the options

const serp = require("serp-extended");

var options = {
  qs : {
    q : "test",
  },
  proxy : "http://username:password@host:port"  
};


const links = await serp.search(options);

You can also use the module simple proxy if you have several proxies (see : https://github.com/christophebe/simple-proxies).

const  serp = require("serp-extended");

var options = {
  qs : {
    q : "test",
  },
  proxyList : proxyList
};

const links = await serp.search(options);

Delay between requests

It is possible to add a delay between each request made on Google with the option delay (value in ms). The delay is also applied when the tool read the next result page on Google.

const serp = require("serp-extended");

var options = {

  qs : {
    q : "test"
  },
  num : 100,
  delay : 2000 // in ms
};

const links = await serp.search(options);

Retry if error

If an error occurs (timeout, network issue, invalid HTTP status, ...), it is possible to retry the same request on Google. If a proxyList is set into the options, another proxy will be used.

const serp = require("serp-extended");

var options = {

  qs : {
    q : "test"
  },
  num : 100,
  retry : 3,
  proxyList : proxyList
};

const links = serp.search(options);

Get the number of results

You can get the number of indexed pages in Google by using the following code.

const serp = require("serp-extended");

var options = {
  host : "google.fr",
  numberOfResults : true,
  qs : {
    q   : "site:yoursite.com"
  },
  proxyList : proxyList
};

const numberOfResults = await serp.search(options);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.