下载包含图像和样式表的网页,以及(可选)通过电子邮件发送该网页 [英] Download web page with images and stylesheets and (optionally) E-mailing it

查看:79
本文介绍了下载包含图像和样式表的网页,以及(可选)通过电子邮件发送该网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

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

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.

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

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.

推荐答案

wget具有-k(--convert-links)选项,该选项会将链接和引用都转换为嵌入式内容(如图像).参见例如获得高级使用(也

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).

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

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.

这篇关于下载包含图像和样式表的网页,以及(可选)通过电子邮件发送该网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆