我正在使用此代码段将谷歌搜索开始使用给定名称:
var parseXlsx = require('excel');
var scraper = require('google-search-scraper');
parseXlsx('foo.xlsx', function(err, data) {
if(err) throw err;
// data is an array of arrays
for(var i=1; i<5; i++){
var stringToSearch = data[i][0];
var options = {
query: stringToSearch,
limit: 1
};
scraper.search(options, function(err, url) {
// This is called for each result
if(err) throw err;
console.log(url)
});
}
});
在foo.xlsx
文件中,我有这一栏:
name1
name2
name3
....
我总是遇到这个错误,我不知道为什么:
Error: Captcha
at Request._callback (C:\Users\user\node_modules\google-search-scraper\index.js:68:23)
at Request.self.callback (C:\Users\user\node_modules\google-search-scraper\node_modules\request\request.js:122:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (C:\Users\user\node_modules\google-search-scraper\node_modules\request\request.js:888:14)
at emitOne (events.js:101:20)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (C:\Users\user\node_modules\google-search-scraper\node_modules\request\request.js:839:12)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
提前感谢。
答案 0 :(得分:1)
错误听起来无法通过RECAPCHA。
错误:CAPCHA
您是否尝试过使用 deathbycaptcha - npm包来解决?
https://www.npmjs.com/package/deathbycaptcha
var scraper = require('google-search-scraper');
var DeathByCaptcha = require('deathbycaptcha');
var dbc = new DeathByCaptcha('username', 'password');
var options = {
query: 'site:edu "information theory"',
age: 'y', // less than a year,
solver: dbc
};
scraper.search(options, function(err, url) {
// This is called for each result
if(err) throw err;
console.log(url)
});