Javascript Cheerio无法获取文本数据
我正在尝试从网站DOM节点获取文本值,并且我正在遵循一些google示例,但是我无法获取文本Javascript Cheerio无法获取文本数据,javascript,cheerio,Javascript,Cheerio,我正在尝试从网站DOM节点获取文本值,并且我正在遵循一些google示例,但是我无法获取文本 const cheerio = require('cheerio'); const request = require('request-promise'); async function iniciar() { const $doc = await request({ uri: '*******************', transform: body =&
const cheerio = require('cheerio');
const request = require('request-promise');
async function iniciar() {
const $doc = await request({
uri: '*******************',
transform: body => cheerio.load(body)
});
const coat_price = $doc('#product-info > div > span.product-content-info-offer-price.offer-price.offer-price-js.product-price-amount-js');
console.log(coat_price)
console.log(coat_price.text())
}
这是输出的数据指令。所选文本输出为空白。
initialize {
'0': {
type: 'tag',
name: 'span',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: [Object: null prototype] {
class: 'product-content-info-offer-price offer-price offer-price-js product-price-amount-js',
'data-amount': ''
},
'x-attribsNamespace': [Object: null prototype] {
class: undefined,
'data-amount': undefined
},
'x-attribsPrefix': [Object: null prototype] {
class: undefined,
'data-amount': undefined
},
children: [ [Object] ],
parent: {
type: 'tag',
name: 'div',
namespace: 'http://www.w3.org/1999/xhtml',
attribs: [Object: null prototype],
'x-attribsNamespace': [Object: null prototype],
'x-attribsPrefix': [Object: null prototype],
children: [Array],
parent: [Object],
prev: [Object],
next: [Object]
},
prev: {
type: 'text',
data: '\n\t\t\n\t\t',
parent: [Object],
prev: null,
next: [Circular]
},
next: {
type: 'text',
data: '\n\t\t\n\t\t\t\t',
parent: [Object],
prev: [Circular],
next: [Object]
}
} .....
}
有人知道会发生什么?
谢谢你的阅读 Maibe问题是我在网页上使用开发工具,而不是在源代码中?