Created
February 24, 2013 18:36
-
-
Save jaen/5024965 to your computer and use it in GitHub Desktop.
Awfully dumb ruby 4chan downloader. Does the job though.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'mechanize' | |
BASE_PAGE_URL = ARGV[0] | |
LAST_PART_REGEXP = /\/([^\/]+)$/ | |
BASE_DIR = LAST_PART_REGEXP.match(BASE_PAGE_URL)[1] | |
`mkdir #{BASE_DIR}` | |
agent = Mechanize.new | |
page = agent.get BASE_PAGE_URL | |
page.links.select { |link| (link.dom_class || "").index "fileThumb" }.each do |image_link| | |
image_filename = LAST_PART_REGEXP.match(image_link.href)[1] | |
puts "Saving #{image_filename}..." | |
`wget -nc -P #{BASE_DIR} -nd http:#{image_link.href}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment