美文网首页
nodejs request cheerio 爬虫

nodejs request cheerio 爬虫

作者: webjiacheng | 来源:发表于2019-01-12 14:09 被阅读0次

爬虫:扒手机号码归属地数据

var request = require("request");
var cheerio = require('cheerio')
var iconv = require('iconv-lite');

var options = { method: 'POST',
url: 'http://www.1234i.com/fj.php',
encoding: null,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
form:
{ haomas: '15521311020%0D%0A13425493936%0D%0A13539995474' } };

request(options, function (error, response, body) {
if (error) throw new Error(error);
var body = iconv.decode(body, 'gb2312');
= cheerio.load(body,{ decodeEntities: false}); var mobileList =('ol').children();
for(let i=0;i<mobileList.length;i++){
console.log(mobileList.eq(i).text().slice(0,-1))
}
});

相关文章

网友评论

      本文标题:nodejs request cheerio 爬虫

      本文链接:https://www.haomeiwen.com/subject/smfcdqtx.html