I am trying to download all the images from a webpage. The images are included as follows:

<img src="https://alwaysSamePart.com/SomeRandomLinkThatVaries.jpg">

How should I parametrize my wget command to specify that I only want the images where the link starts with "https://alwaysSamePart.com/"? because what follows varies every time so I cant just specify a hardcoded link.

wget -r -nd -A jpg --accept-regex "https://alwaysSamePart.com/.*.jpg" https://whatever_domain.com
  • -r allows to go recursively through website (you can specify -l to limit depth)
  • -nd prevents directories creation
  • -A limits download files to jpg images only
  • --accept-regex limits images to needed pattern only
  • didn't work. I tried: wget -E -r -nd -A jpg -P /home/ya/Desktop/myFolder --accept-regex "someStaticLink.*.jpg" whateverDomain.com There are two issues: - I see it only downloads one file in stead of all the images - I get the error "removing fileName since it should be rejected" Feb 6 '16 at 10:51
  • @privetDruzia regex is case sensitive. are you sure it's not your case?
    – rush
    Feb 6 '16 at 11:05
  • no I think it s not : scribd.com/doc/98591038/… Feb 6 '16 at 11:14

did you try -A or equivalent --accept options as given below ?

wget "https://alwaysSamePart.com/" -A "*.jpg"
  • wel the issue is that the images are stored on a website whose URL is totally not the same as the ones where the images are stored. I.e. the images are stored on www.randomWebsite.com and in the html code of the page you have a url like ""alwaysSamePart.com/SomeRandomLinkThatVaries .jpg". So shouldn't I first try to specify I only want the images from the urls on the webpage. Because imagine some other website stores its images on "alwaysSamePart.com/SomeSLIGHTLYDIFFERENTRandomLinkThatVaries .jpg " What would prevent me from downloading all their images too? I'd have gigs... Feb 5 '16 at 20:47
  • tried it: didn't work. error 403 Feb 5 '16 at 20:52
  • I have to specify exactly what link. So ideally I'd have to scrape all the urls out of the webpage and then surf to each url individually and then finally save each image. Feb 5 '16 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.