Created
September 7, 2009 15:04
-
-
Save ucnv/182402 to your computer and use it in GitHub Desktop.
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 'nokogiri' | |
require 'open-uri' | |
url = 'http://www.melon-peach.com' | |
ua = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2' | |
html = Nokogiri.parse(open(url, 'User-Agent' => ua).read) | |
html.xpath('//img[contains(@src, "/small")]').each_with_index do |img, i| | |
data = open(url + '/userimages/' + img['src'].sub(%r{/small}, '/big'), 'User-Agent' => ua).read | |
data.gsub!( | |
/\xFF\xDA\x00\x0C\x03\x01[\s\S]\x02[s\S]\x03[\s\S]/, | |
"\xFF\xDA\x00\x0C\x03\x01\x11\x02\x11\x03\x00" | |
) | |
File.open("#{'%02d' % i}.jpg", 'w') {|f| f.write data } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment