{ [Error: connect ETIMEDOUT 8.7.198.45:443
] code: ‘ETIMEDOUT’, errno: ‘ETIMEDOUT’, syscall: ‘connect’, address: '8.7.198.45
', port: 443 } [Finished in 22.6s]
代码如下:
var request = require(‘request’); var cheerio = require(‘cheerio’);**** var url = ‘https://www.youtube.com ‘; function crawler(url,callback){ var list = []; request(url,function(err,res){ if(err){ return callback(err); } var $ = cheerio(res.body.toString()); var s = $(’*’).text(); console.log(‘s=’+s); }); callback(null,list); };
crawler(url,function(err,list){ if(err){ return console.log(err); } console.log(list); });
你本地能访问 YouTube 么?
可以啊,本地翻墙
你给终端也上代理
是不是代码里面 请求头写代理?
代理获取吧