Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pull image links from a website and download them using wget?

Tags:

linux

wget

I really want to download images from a website, but I don't know a lot of wget to do so. They host the images on a seperate website, how I do pull the image link from the website using cat or something, so I could use wget to download them all. All I know is the wget part. Example would be Reddit.com

  wget -i download-file-list.txt
like image 636
c0rruptbytes Avatar asked Jul 29 '12 04:07

c0rruptbytes


2 Answers

Try this:

wget -r -l 1 -A jpg,jpeg,png,gif,bmp -nd -H http://reddit.com/some/path

It will recurse 1 level deep starting from the page http://reddit.com/some/path, and it will not create a directory structure (if you want directories, remove the -nd), and it will only download files ending in "jpg", "jpeg", "png", "gif", or "bmp". And it will span hosts.

like image 96
Jon Lin Avatar answered Nov 15 '22 11:11

Jon Lin


I would use the perl module WWW::Mechanize. The following dumps all links to stdout:

use WWW::Mechanize;

$mech = WWW::Mechanize->new();
$mech->get("URL");
$mech->dump_links(undef, 'absolute' => 1);

Replace URL with the actual url you want.

like image 27
Thor Avatar answered Nov 15 '22 10:11

Thor