简体   繁体   English

如何从网站下载所有图像?

[英]How to download all images from a website?

I want to download multiple images from the following website: www.bbc.co.uk I want to do it by using PHP cURL, can someone help lead me in the right direction? 我想从以下网站下载多个图像:www.bbc.co.uk我想通过使用PHP cURL来实现,有人可以帮助我朝着正确的方向前进吗?

It would be nice to download all the images in one shot, but if someone can help me download maybe download just 1 or a bunch that would be great! 一次性下载所有图像会很不错,但是如果有人可以帮我下载,可能只需下载一个或一堆就可以下载!

Edit: it would be a good idea to show what I have tried: 编辑:显示我尝试的内容是个好主意:

<?php
$image_url = "www.bbc.co.uk";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/jpeg");
print $image;
?>

For some reason it is not working. 由于某种原因,它无法正常工作。 It is to be noted I am an absolute amatuer at PHP and programming in general. 值得注意的是,我一般都是PHP和编程的绝对主义者。

The above code you pasted isn't doing what you think it is. 您粘贴的上述代码没有按照您的想法执行。

$image = curl_exec($ch);

The $image variable doesn't contain any image, it actually contains the entire HTML of that webpage as a string. $image变量不包含任何图像,它实际上包含该网页的整个HTML作为字符串。

If you replace 如果你更换

// output to browser
header("Content-type: image/jpeg");
print $image;

with: 有:

var_dump($image);

You will see the html. 你会看到HTML。

Something like this: 像这样的东西:

卷曲输出

Try to find the actual champion image source and parse it accordingly 尝试找到实际的冠军图像源并相应地解析它

You just need the whole /Air/assets/images/champions folder right? 你只需要整个/ Air / assets / images / champions文件夹吗?

Nothing easier when you use FireFox and a Download plugin like "Download Them All", open the FTP folder (Eambo's link) where the champions' pictures are located, right clic, select the plug-in. 当你使用FireFox和像“下载它们全部”这样的下载插件时,打开冠军图片所在的FTP文件夹(Eambo链接),右键,选择插件,没有什么比这更容易了。
It's gonna list all the files, select them all or select those you need and start the download. 它将列出所有文件,全部选择或选择您需要的文件并开始下载。

Also, if you own that game you can take a look in this path: 此外,如果您拥有该游戏,您可以查看此路径:

\League of Legends\rads\projects\lol_air_client\releases\<newest-version>\deploy\assets\images\champions  

Since you will probably use that in your university, CHECK THIS and I hope you will find a solution. 既然您可能会在大学使用它,请检查一下,我希望您能找到解决方案。

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

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