如何在PHP中使用wget或curl获取网页上所有路径/文件的列表? [英] how to get a list of all paths/files on a webpage using wget or curl in php?

查看:224
本文介绍了如何在PHP中使用wget或curl获取网页上所有路径/文件的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 wget -p $ url 来获取网页上的所有文件,以便我可以获取列表。但是对于一些URL,事实证明只有index.html可以被wget获取。有没有办法通过wget或cURL获取特定URL上的文件列表?我需要检查请求头和响应头吗?

I use wget -p $url to get all the files on a webpage so that I can get a list. But for some URLs, it turns out that only the index.html can be fetched by wget. Is there a way to get a list of files on a specific URL by wget or cURL? Do I need to check the request headers and response headers?

推荐答案

有些服务器不允许您浏览目录列表,如果有这个目录中的默认文档,它接管了,你也无法浏览。

Some servers do not let you browse directory listings, and if there's a default document in that directory, it takes over and you can't browse either.

你需要实现一个解析所有路径,文件和链接的蜘蛛,创建在HTML中声明和使用的文件的目录结构。 然后,您可以下载这些文件。

You need to implement a spider that parses all the paths and files and links, and creates a directory structure of files that are declared and used in the HTML. Then you can download those files.

这篇关于如何在PHP中使用wget或curl获取网页上所有路径/文件的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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