我正在查看一个只是目录索引的网页。索引包含文件夹和文件,某些文件夹包含具有文件夹等的文件夹。
有没有办法提供目录的url并让PHP下载所有文件并按相同顺序放置?
答案 0 :(得分:1)
function downloadLinks($url, $directory = './')
$contents <- HTML of $url
$links <- parse $contents and extract URLs to files and directories
if $directory does not exist
mkdir($directory)
foreach $links as $link
if $link is a directory
downloadLinks($url . $link, $directory . $link)
else
downloadFile($url, $directory . $filename)
downloadLinks('http://example.com/')