[英]Download all images from a single directory of a website
I need to get all of the images from one website that are contained all in one folder. 我需要从一个网站获取所有图像,这些图像都包含在一个文件夹中。 Like for instance, (site.com/images/.*). 例如,(site.com/images/.*)。 Is this possible? 这可能吗? If so, whats the best way? 如果是这样,最好的方法是什么?
Do you have FTP access? 你有FTP访问权限吗?
Do you have shell access? 你有shell访问权限吗?
With Linux it's pretty easy. 使用Linux它非常简单。 Not sure about windows. 关于窗户不确定。
wget -H -r --level=1 -k -p http://example.com/path/to/images
Edit: Just found wget for windows . 编辑:刚找到wget for windows 。
Edit 2: I just saw the PHP tag, in order to create a PHP script which downloads all images in one go, you will have to create a zip (or equivalent) archive and send that with the correct headers. 编辑2:我刚看到PHP标签,为了创建一个可以一次性下载所有图像的PHP脚本,您必须创建一个zip(或等效的)存档并使用正确的标头发送。 Here is how to zip a folder in php , it wouldn't be hard to extract only the images in that folder, just edit the code given to say something like: 这里是如何在php中压缩文件夹,只提取该文件夹中的图像并不难,只需编辑给出的代码,例如:
foreach ($iterator as $key=>$value) {
if (!is_dir($key)) {
$file = basename($key);
list($name, $ext) = explode('.', $key);
switch ($ext) {
case "png":
case "gif":
case "jpg":
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
break;
}
}
}
如果网站允许索引,你需要做的就是wget -r --no-parent http://site.com/images/
如果您想查看网页正在使用的图像:如果您使用的是Chrome,则可以按F-12(或在菜单中找到“开发人员工具”),在“资源”选项卡上,左侧有一棵树,然后在“框架”下,您将看到“图像”文件夹,然后您可以看到该页面中列出的所有图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.