当使用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')
但是,由于它是阴影组件,因此上面的代码不起作用。
对此有任何解决方法吗?
你不能。您应该使用puppeteer库来获取在运行时创建的内容。https://github.com/puppeteer/puppeteer/issues/858#issuecomment-441429302