创建一个PHP文件,从某个站点下载所有链接 [英] Creating a PHP file that downloads all links from a certain site

查看:157
本文介绍了创建一个PHP文件,从某个站点下载所有链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的firefox中安装了附加的DownThemAll,当我看到它下载了大量的pk3文件(一个开源的第一人称射击游戏的地图文件),我想知道我是否可以用PHP做同样的事情。



这是我在想的:

  foreach(glob http://www.someaddress.ext/path/*.pk3)as $ link){
// do something to download ...
}

是的,就我所知道的。我想知道,只是通过流式启动下载即可实现...我不太了解我的方式,这不是我通常用PHP做的,而是触发了我的兴趣。



那么有谁知道如何解决这个问题?

解决方案

我将你抛出正确的方向。



cURL 用于下载,并使用正则表达式获取链接中的所有路径。



请注意,一个网站可以是一个相对链接。所以你需要检查。


I recently installed the add-on "DownThemAll" into my firefox and as I watched it download a huge amount of pk3 files(map files for an opensource First Person Shooter), I wondered if I could do the same with PHP.

Here's what I'm thinking:

foreach(glob("http://www.someaddress.ext/path/*.pk3") as $link) {
  //do something to download...
}

Yeah that's about as far as I've gotten. I'm wondering wheter to just initiate a download of to do it via a stream... I don't really know my way around this material, it's not what I usually do with PHP, but it's triggered my interest.

So is there anybody who knows how to tackle this problem?

解决方案

I'll throw you in the right direction.

cURL for the downloading and a regular expression to get all the paths in the link.

Beware though, a link on a site can be a relative link. So you need to check for that.

这篇关于创建一个PHP文件,从某个站点下载所有链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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