如何从水疗中心动态渲染HTML
上下文
我正在尝试使用javascript fetch命令返回leetcode.com网页的html,但是当我这样做时,返回的html处于预渲染的状态,即兴趣的div div是空的:
<div id="app"></div>
当我加载的页面时但是,对我的浏览器并检查元素的兴趣,我可以看到,由于LeetCode使用单页应用技术,因此这个“应用程序” div会填充动态内容。此渲染必须在fetch命令执行后发生。
问题
我想知道如何使用fetch命令或类似来检索完全渲染的网页的HTML。我想这样做以刮擦一些仅在网页完全渲染之后才出现的内容。
假设
我假设fetch命令无法返回JavaScript呈现的HTML,即类似于您在vue.js或react.js中找到的html。
Context
I'm trying to use the javascript fetch command to return the HTML of a leetcode.com webpage, but when I do the returned HTML is in a pre-rendered state i.e. the div of interest is empty:
<div id="app"></div>
When I load the page of interest with my browser and inspect element however, I can see that this "app" div gets populated with dynamic content as leetcode uses single-page-application technology. This rendering must be happening after the fetch command executes.
Question
I would like to know how to use the fetch command or similar in order to retrieve the html of a fully rendered webpage. I would like to do this to scrape some content which only appears after the webpage has been fully rendered.
Assumptions
I'm assuming that the fetch command cannot return html that gets rendered by javascript, i.e. similar to what you'll find with vue.js or react.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论