0

Is there a way to download forum jpeg image attachments, possibly using Wget or Curl or some other tool? I would like to download jpeg attachments from specific pages on forums. I'm not interested in downloading all forum attachments, but attachments specific to a page in a thread. I also don't want to download attachments one at a time. I want to be able to go to a page on a forum and download all attached images from that page using one command/action.

I can retrieve forum attachment urls by using the Firefox Addon Copy All Links:

http://forum.sample.com/attachmentshow.php?attachmentid=5332197&d=1391102903
http://forum.sample.com/attachmentshow.php?attachmentid=5332198&d=1391102903
http://forum.sample.com/attachmentshow.php?attachmentid=5332199&d=1391102903
http://forum.sample.com/attachmentshow.php?attachmentid=5683368&d=1407242372

But it would be more convenient if I could give Wget or Curl (or some other tool) the url of the forum page, and the command would automatically retrieve the attachment urls and download the images.

1

For obtaining links to images or files that don't necessarily use a filename suffix in the URL, I would use wget with the --accept-regex option. I have changed the script I have used to your specific case:

wget -nd -r -l 2 --accept-regex '/attachmentshow' www.domain.tld

Explanation:

  • -nd no-directories, to prevent creating to hierarchy of directories when retrieving recursively.
  • -r enable recursive retrieving, see Recursive download for details.
  • -l specify the recursion maximum depth level, might want to change this to your specific intentions.
  • --accept-regex specify a regular expression to accept the URL.

You could also use -A to specify which filename suffixes should be accepted, see Recursive Accept/Reject Option for details.

When encountering robots.txt you could use the option -e robots.off to ignore robots.txt files. I do advise reading about the option and the consequences first.

You can read more about wget on the manual page.

I hope you are able to tweak the example to your needs and solve the problem.

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.