在使用axios执行GET请求时,我检索到以下HTML正文:
request:
axios.get(URL)
.then((response) => result = response.data)
body of 'result':
<body>
<custom-component></custom-component>
</body>当通过Chrome查看custom-component时,我可以看到有很多我想访问的孩子。
例如:
<custom-component>
<div class="header-container">...</div>
</custom-component>通常,使用cheerio,我可以通过以下命令访问这些内容:
const $ = await cheerio.load(result);
$('.header-container')但是,由于它是一个影子组件,所以上面的代码不起作用。
对此有什么解决方法吗?
发布于 2020-03-28 04:05:03
你不能。你应该使用puppeteer库来抓取在运行时创建的东西。https://github.com/puppeteer/puppeteer/issues/858#issuecomment-441429302
https://stackoverflow.com/questions/60893090
复制相似问题