下载包含图像和样式表的网页并(可选)通过电子邮件发送

发布于 2024-08-12 13:48:02 字数 440 浏览 3 评论 0原文

我需要使用 PHP 以编程方式制作网页快照,并将它们放入 HTML 电子邮件中。

我尝试了wget --page-requirements。它可以正常下载所有内容,但不会更改 HTML 页面的源代码以指向下载的文件而不是在线原始文件。而且,该 HTML 当然距离在 HTML 电子邮件中正确显示还有很长的路要走。

我很想知道是否有现成的解决方案。我已经对拍摄 HTML 快照并相应更改 HTML 的解决方案感到满意了。能够通过电子邮件发送这将是锦上添花。

我控制网页快照,因此我可以调整内容以优化结果。

我的服务器端平台是 PHP,但通过非常自由的设置,我可以在 PHP 中执行 wget 和 Perl 脚本之类的东西。但是,我没有 root 访问权限,也无法安装其他软件包或程序。

任务是在每次有人下订单时制作产品页面的快照,以便有关于当时页面的样子的文档。

I need to make snapshots of web pages programmatically using PHP and get them into a HTML E-Mail.

I tried wget --page-requisites. It downloads everything all right, but it doesn't change the HTML page's source code to point to the downloaded files rather than the on-line originals. Also, that HTML is of course a long way from being displayed properly in a HTML E-Mail.

I am interested to know whether there are ready-made solutions for this. I would already be happy with a solution that takes a HTML snapshot and changes the HTML accordingly. Being able to E-Mail it would be the icing on the cake.

I control the web pages being snapshot, so I have the possibility to adjust the content to optimize the results.

My server-side platform is PHP but with very liberal settings, I can execute things like wget and Perl scripts from within PHP. I do however not have root access and can not install additional packages or programs.

The task is to make a snapshot of a product page each time somebody places an order, so there is documentation about what the page looked like at the time.

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

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

发布评论

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

评论(2

紅太極 2024-08-19 13:48:02

wget 有一个 -k (--convert-links) 选项,它将链接和引用转换为嵌入内容(如图像)。请参见例如 wget 高级使用(也此处)。

对于您问题的电子邮件部分 - 我确信您可以使用现有的库之一。例如,PHP 有一些 PEAR 包(不记得确切的名称)来处理 HTML 电子邮件;我很确定 Perl 和 Python 都有类似的东西。

wget has a -k (--convert-links) option, which will convert both links and references to embedded content (like images). See e.g. wget advanced use (also here).

For the email-part of your question - I'm sure you can use one of the existing libraries. For example, PHP has some PEAR package (do no remember the exact name) to handle HTML emails; I'm pretty sure both Perl and Python have something similar.

风向决定发型 2024-08-19 13:48:02

在这种情况下,您尝试使用 wget 进行网站镜像。简单的解决方案是使用 httrack 这是一个简单的命令行工具。它非常强大且可配置,请尝试一下!
httrack 网站提供了一个 GUI,但您不需要它,一切都可以通过命令行(或 PHP)实现。

In this case, you try to do a website mirroring using wget. The simple solution is to use httrack which is a simple command-line tool. It's very powerful and configurable, try it!
The httrack website presents a GUI, but you don't need it, all is possible from the command-line (or from PHP).

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