Cheerio给出奇怪的结果

Ash*_*hok 7 node.js cheerio

这是一个简单的cheerio 应用程序。该标签有一个名为 product-link 的类,我想访问它的 href,但是当我控制台记录这个时,我没有得到任何 html。任何人都可以对正在发生的事情以及如何从中获取我想要的数据有所了解吗?

let holder = $('.product-link');
console.log(holder);
Run Code Online (Sandbox Code Playgroud)

结果->

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,
        normalizeWhitespace: false,
        xml: false,
        decodeEntities: true },
     length: 1,
     _root: [Circular] },
  length: 0,
  prevObject:
   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,
        normalizeWhitespace: false,
        xml: false,
        decodeEntities: true },
     length: 1,
     _root: [Circular] } }
Run Code Online (Sandbox Code Playgroud)

Ash*_*hok 0

对于仍然面临相同问题的任何人,如果您在使用 Cheerio 时没有获得正确的 HTML,您可以使用 Puppeteer 模拟浏览器,打开网页直到加载所有内容,然后使用 Cheerio 解析来自 puppeteer 的 HTML。