我在控制檯中運行正常的example1.js nodejs文件如何在Web瀏覽器中顯示控制檯內容?
如何使用http請求在Web瀏覽器中顯示?
var request = require('request');
var cheerio = require('cheerio');
request('news.ycombinator.com', function (error, response, html) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html);
$('span.comhead').each(function(i, element){
var a = $(this).prev();
console.log(a.text());
});
}
});
var request = require('request'); var cheerio = require('cheerio'); request('https://news.ycombinator.com',function(error,response,html)if(!error && response.statusCode == 200){0} {0} {0} cheerio.load(html); (),; $('span.comhead')。each(function(i,element)var a = $(this).prev(); console.log(a.text()); }); } }); – user3610906