A
A
Arsen Asatryan2020-08-24 15:42:24
Parsing
Arsen Asatryan, 2020-08-24 15:42:24

How to download a large number of photos from a donor site with links to them?

There is a file with links (photos), about 4k. Do they all need to be downloaded? Manually this is generally nonsense) How to automate the process?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2020-08-24
@arsen1717

than
wget https://ya.ru/111.jpeg
it is possible through curl, but as a rule, wget is already available and curl must be installed.
How to download, a list in a file
How to insert in puff

S
Sergey Pugovkin, 2020-08-24
@Driver86

Is this a large number? That's 15 million - big! (it was the case)
So you can:

<?php
$urls = [
    'http://foto.com/1.jpg',
    'http://foto.com/2.jpg',
    //...
];
foreach ($urls as $i => $url) {
    file_put_contents(__DIR__ . "/{$i}.jpg", file_get_contents($url));
}
echo "OK\n";

Save as file.php and run with the command in the console: php -f file.php
UPD 08/25/2020
Just now I accidentally noticed:
5f43c10843940381430660.png
the real name of the file is file.txt.txt in the same place (because the file extension is hidden, as can be seen from the names photos).
Those. it was necessary to run the command like this: wget -ic:/users/arsen/file.txt.txt
Or return the file name back to file (i.e. true it will be like file.txt)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question