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