简体   繁体   English

如何在PHP中保存从HTTP请求下载的所有资源

[英]How to save all resources downloaded from a HTTP request in PHP

Is it possible to save all resources downloaded from a HTTP request with PHP? 是否可以使用PHP保存从HTTP请求下载的所有资源?

For example: using curl, wget or similar to get all files necessary to load the page in browser instead of only getting the HTML content of the page. 例如:使用curl,wget或类似方法获取在浏览器中加载页面所需的所有文件,而不是仅获取页面的HTML内容。

I don't want to get all links and then download each link with a direct curl. 我不想获取所有链接,然后直接直接下载每个链接。 I would like a way to do it only once. 我只想做一次。 I assume it's possible since in a browser I also only do one url request to get all resources. 我认为这是可能的,因为在浏览器中我也只执行一个url请求来获取所有资源。

Edit: The point here is to simulate the browser behavior. 编辑:这里的重点是模拟浏览器的行为。 How can I save an entire page with PHP. 如何使用PHP保存整个页面。 If it must be done with several steps what should be the logic to follow? 如果必须通过几个步骤来完成,应该遵循的逻辑是什么? I have huge problems in getting all files from a page even after extracting links since I find it very hard to store session data and reuse it for further curls. 即使在提取链接后,也无法从页面获取所有文件,因为我发现很难存储会话数据并将其重新用于进一步卷曲,这给我带来了很大的问题。

You can use Ajax for that and save that as objects and show them when needed. 您可以为此使用Ajax并将其另存为对象,并在需要时显示它们。 does that works for you? 对您有用吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM