Google-serp 用headless浏览器抓取Google搜索结果
Google-serp 用headless浏览器抓取Google搜索结果
Node.js HTTP工具
共24Star
详细介绍
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 Star
-
777 Star
-
0 Star
-
20 Star
-
5 Star
-
0 Star
-
1117 Star
-
0 Star
-
284 Star
-
64 Star