"Error: Capture" while returning URL from Node.js

"Error: Capture" while returning URL from Node.js

我正在使用此代码段 Google 搜索从给定名称开始:

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。

Error: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)
});