问题描述
我正在尝试使用抓取工具获取该网站的数据:https://www.cofgi.org/farmacies/farmacies-de-guardia
网站的contain是一个表格,我想获取每一行,每一个td数据。
这是我的代码:
async function init(day,repositories) {
return axios({
method: 'post',url: 'https://www.cofgi.org/farmacies/farmacies-de-guardia',config: { headers: {'Content-Type': 'application/x-www-form-urlencoded'}}
})
.then(async (response) => {
const $ = cheerio.load(response.data);
console.log($('·#pharmacies-of-guard-data-table'));
$('#pharmacies-of-guard-data-table > tbody > tr > td.data').each(() => {
console.log($(this).text());
});
})
.catch((error) => {
console.error(error)
});
}
我没有得到任何 html。这就是console.log($('·#pharmacies-of-guard-data-table'));
打印的内容:
initialize {
options: {
withDomLvl1: true,normalizeWhitespace: false,xml: false,decodeEntities: true
},_root: initialize {
'0': {
type: 'root',name: 'root',namespace: 'http://www.w3.org/1999/xhtml',attribs: [Object: null prototype] {},'x-attribsNamespace': [Object: null prototype] {},'x-attribsPrefix': [Object: null prototype] {},children: [Array],parent: null,prev: null,next: null
},options: {
withDomLvl1: true,decodeEntities: true
},length: 1,_root: [Circular]
},length: 0,prevObject: initialize {
'0': {
type: 'root',_root: [Circular]
}
}
知道为什么我会收到这样的回复吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)