[英]Download images from PHP page that loops images
I am wanting to download images from a web page (.php) that seems to loop through images when the page is reloaded.我想从 web 页面 (.php) 下载图像,该页面在重新加载页面时似乎会循环显示图像。
If I open the page such as example-photographer.com/library/images.php it shows a single image.如果我打开诸如 example-photographer.com/library/images.php 之类的页面,它会显示一个图像。 No option to see others (like slideshow navigation).
没有查看其他人的选项(如幻灯片导航)。 If I reload the page a new image appears.
如果我重新加载页面,则会出现一个新图像。
I'd like to create a script of some sort that accesses the page and downloads the image presented, then continues for a given amount (say 50 images) before stopping.我想创建一个访问页面并下载呈现的图像的某种脚本,然后在停止之前继续给定数量(比如 50 个图像)。 I have noticed that sometimes the image showing after refresh is one that has already shown before.
我注意到有时刷新后显示的图像是之前已经显示的图像。 So it seems to just pick a random one from the library.
所以它似乎只是从图书馆中随机挑选一个。
I also noticed that when right click and downloading the image it is always the same name (image.jpeg).我还注意到,当右键单击并下载图像时,它总是同名(image.jpeg)。 So I'm thinking the script would need a way to rename the file to avoid overwrite?
所以我认为脚本需要一种重命名文件以避免覆盖的方法?
Thanks in advance.提前致谢。 I have minimal experience with coding but can usually figure things out after getting a base level suggestion on how to do it.
我对编码的经验很少,但通常可以在获得有关如何做的基本建议后弄清楚。
You could even use for simplicity the famous $data = file_get_contents($url)
to read the image then write it to a local file using file_put_contents($filename, $data)
.为简单起见,您甚至可以使用著名的
$data = file_get_contents($url)
来读取图像,然后使用file_put_contents($filename, $data)
将其写入本地文件。
for ($i = 0; $i < 5; $i++) {
$url = "https://i.stack.imgur.com/RhfH5.jpg?s=48&g=1&i=$i";
$data = file_get_contents($url);
file_put_contents("test$i.jpeg", $data);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.