编辑 html 页面并重新显示 PHP

发布于 2024-09-09 20:17:45 字数 155 浏览 2 评论 0原文

因此,我一直在使用一种方法从网站检索图像,但我认为简单地显示页面而不显示一些我不想显示的详细信息可能会更容易。该网站特别知道我们正在这样做,因此不应该出现任何法律问题。那么是否可以在 PHP 中打开 html 页面,搜索每个页面中相同的特定内容,将其删除,然后在浏览器中重新显示带有新编辑的页面?

So I have been using a method to retrieve images from a website but I thought it may be easier to simply show the page without some details I don't want displayed. The website in paticular know we are doing this so there shouldn't be any legal complications. So would it be possible to open the html page within PHP, search for a specific that would be the same in each page, remove it and then redisplay the page within the browser with its new edits?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命比纸薄 2024-09-16 20:17:45

您可以使用 TidyHTML Purifier 库,用于清理和导航文档树、查找您要查找的元素并将其删除。我找不到 Tidy 的综合文档,但 php.net 上的示例应该足以帮助您入门。

You can use the Tidy or HTML Purifier libraries to clean up and navigate the document tree, find the elements you are looking for, and remove them. I can't find comprehensive docs for Tidy, but the examples on php.net should be enough to help you get started.

俯瞰星空 2024-09-16 20:17:45

是的,这是可能的,您需要使用 file_get_contents( "http://url"); 将页面加载到字符串中,然后 preg_replace 使用正则表达式来清理字符串。

Yes this is possible, you'd need to use file_get_contents("http://url"); to load the page into a string, then preg_replace with a regex to clean the string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文