从js节点返回URL时出现错误
我正在使用这个片段,使谷歌search开始到一个给定的名字:
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)
提前致谢。
错误听起来像不能通过一个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) });