Tag: 加油

使用cheerio获取页面的标题

我试图得到与cheerio的URL的标题标签。 但是,我得到空string值。 这是我的代码: app.get('/scrape', function(req, res){ url = 'http://nrabinowitz.github.io/pjscrape/'; request(url, function(error, response, html){ if(!error){ var $ = cheerio.load(html); var title, release, rating; var json = { title : "", release : "", rating : ""}; $('title').filter(function(){ //var data = $(this); var data = $(this); title = data.children().first().text(); release = data.children().last().children().text(); json.title = title; json.release = […]