0.1.10 • Published 7 years ago

google-serp v0.1.10

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Google-serp

Scrape Google search results using Phobetor and Nightmare.js

How to use it?

// yarn add google-serp
const googleSerp = require("google-serp")
const serpResults = googleSerp({
  query:"Led Zeppelin"
}).then(console.log)

Output:

{
  type:"result",
  payload:[
    {
      url:"https://ledzeppelin.com",
      title: "Homepage of one rock and blues legend",
      description:"Led Zeppelin is not a misic you will easily forget",
      position: 1
    },
    ...
  ]
}

Typing

type SerpResult = {
  url: String,
  title: String,
  description: String,
  position: Number,
}

type Result = {
  payload:Array<SerpResult> | Error,
  type: "result" | "error"
}

googleSerp({
  query: String,
  showHundredFlag?: Boolean,
  show?: Boolean,
}): Promise<Result>

If there is an error during scraping, the library will return Object with type equal to "error" and the error as a payload. If process is successful, the library will return Object with type equal to "result" and array of results as payload .

Arguments

  • query

Google search query

  • scrapeHundredFlag

If set to true, it will request 100 search result instead of 10

Default value - false

  • show

If set to true, it will show the browser

Default value - false

Requirements

Electron compatible environment, i.e. either system with graphic interface or you need to use xvfb. In the latter case you need to do something like that https://gist.github.com/omarusman/1af968d9b96fc5b0cd39599db3f2b9bd

Changelog

  • 0.1.7 fix error occuring when there is element with no description
  • 0.1.6 fix error with exporting unexisting file in v0.1.5
0.1.10

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago