Node can't scrape certain pages

ぃ、小莉子 提交于 2019-12-24 03:47:16

问题


I don't know if this is something to do with coldfusion pages or what but I can't scrape these .cfm pages

In the command line in a directory with request run:

node> var request = require('request');
node> var url = 'http://linguistlist.org/callconf/browse-conf-action.cfm?confid=173395';
node> request(url, function (err, res, body) { if (err) { console.log(err) } else { console.log('body:', body) }; });

I've tried with some other .cfm sites but they work, and am only getting blank results so I don't know what it could be

Note: I've also tried doing it the barebones require('http').get(url,…) route but I get the same blank result


回答1:


I GOT IT ! (finally)

This web server really need to know how to answer to you. Try this (it work for me)

var request = require('request');
var options = {
  url: 'http://linguistlist.org/callconf/browse-conf-action.cfm?confid=173395',
  headers: {
   'Accept-Encoding':'none'
  }
};
request(options, function (err, res, body) { if (err) { console.log(err) } else { console.log('body:', body) }; });


来源:https://stackoverflow.com/questions/29862664/node-cant-scrape-certain-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!