问题描述
我正在尝试从网站DOM节点获取文本值,并且正在关注一些Google示例,但无法获取文本。
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,children: [ [Object] ],parent: {
type: 'tag',name: 'div',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',prev: null,next: [Circular]
},next: {
type: 'text',data: '\n\t\t\n\t\t\t\t',prev: [Circular],next: [Object]
}
} .....
}
有人知道会发生什么吗? 感谢您的阅读!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)