试图抓住此页面上的价格元素:
在运行console.log
时无法获得任何建议吗?我已经检查过我选择了正确的元素。
var request = require('request');
var cheerio = require('cheerio');
var url = 'http://us.asos.com/asos/asos-bomber-jacket-in-khaki/prd/5773457?iid=5773457&affid=14174&channelref=product%20search&mk=abc¤cyid=2&gclid=CIvXk9DEt88CFYpehgodLo0Ivg';
request(url , function(error, response, html) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html);
$('span.current-price').each(function(i, element){
console.log($(this).text());
})
答案 0 :(得分:0)
我在HTML中看到的current-price
是:
<div class="current-price">
因此,$('span.current-price')
与此不匹配。
你需要:
$('div.current-price')
或只是
$('.current-price')