1

我正在做这个项目,我基本上需要能够在任何页面上放置一个 html 按钮(可以受登录保护),一旦用户点击该按钮,页面 html 和依赖项(css、js、图像等)应该发送到远程服务器。

最初,我通过使用 iframe 和隐藏表单并在用户单击按钮时将页面的 url 发布到远程服务器来使其工作。然后我在 exec 中使用 wget 来获取页面和依赖项。但是,这显然不适用于受保护的页面。

所以我的下一个方法是通过表单将页面的 innerHTML 发送到远程服务器上的 php 脚本。然后我尝试使用 simplehtmldom 运行 , 和 tags ,将相对 url 转换为绝对 url ,将它们存储在数组中,并将 url 替换为同一目录中的路径。然后我在所有数组上应用了 wget 并下载了这些依赖项。

但是,我再次陷入困境,因为 CSS 中有背景图像,而 javascript 中有嵌入的 html 代码。

有人可以提出更好的解决方案吗?

谢谢

4

1 回答 1

0

I'm not sure that this is ever going to work. The fact is that unless your site is very simple indeed (i.e. has very few dynamic parts) and exists on the click->load->static paradigm which really isnt the way any modern site works anymore, you're always going to have some missing pieces/dependencies.

If it's a super simple site you can perhaps just send the html and then add in a <base> href to the head of the duplicate?

As you know, these days sites are more like applications and your really need the whole site inclusive of all 'moving parts'

other things which might be worth looking at:

  1. Using ftp functions of PHP/.NET/Java/Ruby etc to fire template/css/img directories to a new location.
  2. perhaps looking at the HTML 2 PDF/Canvas tools which are out there and can show a visual representation of the current state of the site to another location.
于 2012-05-17T19:59:39.637 回答