Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含爬虫提供的动态内容的页面。但有时此内容在 HTML 中存在问题(没有关闭标签、标签关闭而不打开等)。所以,这个错误的内容破坏了整个页面,因为关闭或打开了他们不应该打开的东西。
HTML的常见错误。
<div><p>foo</p>
<p>bar</p></div>
<p><a>link</p></a>
如何将此内容放入沙箱中以不破坏页面?由于 SEO,无法使用 iframe。
如何处理动态内容以找出哪些标签尚未关闭,并(使用堆栈)在末尾或必要时添加它们(以确保正确的标签嵌套)?但是,如果您这样做,我建议在客户端执行此操作。