我在NodeJs Cheerio中做错了什么

时间:2016-10-01 02:21:37

标签: node.js web-scraping cheerio

var cheerio = require('cheerio');
var request = require('request');
request('https://www.mobcrush.com', function(err, resp, body){
    if(!err && resp.statuscode == 200){
        var $ = cheerio.load(body)
        var testing = $('#main-content')
        console.log(testing)
    }
});

尝试抓取网站,但控制台日志显示空白

1 个答案:

答案 0 :(得分:1)

一切都很好

您已statusCode而不是 try { if (!err && resp.statusCode == 200) { console.log('ssss'); var $ = cheerio.load(body) var testing = $('#main-content'); console.log(testing); } } catch (e) { console.log(e) }

 var phrasesCount = await db.Phrases.CountAsync();