如何使用PHP下载HTML? [英] How to download HTML using PHP?

查看:80
本文介绍了如何使用PHP下载HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从PHP中的URL下载HTML文件,并下载所有依赖项(如CSS和Images)并将它们作为文件存储到服务器中?我要求太多吗?

How do I download an HTML file from a URL in PHP, and download all of the dependencies like CSS and Images and store these to my server as files? Am I asking for too much?

推荐答案

最简单的方法是使用 wget 。它可以递归下载HTML及其依赖项。否则,您将自己解析html。有关在纯PHP中执行此操作的详细信息,请参见Yacoby的答案。

The easiest way to do this would be to use wget. It can recursively download HTML and its dependencies. otherwise you will be parsing the html yourself. See Yacoby's answer for details on doing it in pure php.

这篇关于如何使用PHP下载HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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