Created
May 26, 2013 02:48
-
-
Save D3MZ/5651537 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
#For Growth Hacking Services/Consulting, feel free to shoot me an Email :) | |
#Author: Demetrius Michael | |
#Contact: arrrwalktheplank (at) gmail.com | |
#http://www.demetriusmichael.com/ | |
require 'mechanize' | |
require 'peach' | |
require 'pathname' | |
def get_images_from_ page | |
page.search('.restore img'). | |
select { |x| x.attributes["onload"].value == "NcodeImageResizer.createOn(this);" if x.attributes["onload"] } | |
end | |
urls = (1..33).collect { |n| "http://www.audizine.com/forum/showthread.php/332328-***-OFFICIAL-B8-A4-Wheel-Gallery-***/page#{n}" } | |
a = Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
images = [] | |
urls.pmap(10) do |url| | |
page = a.get url | |
images += get_images_from_ page | |
end | |
images = images.flatten.uniq | |
save_dir = ENV['HOME']+"/audiwheels/" rescue | |
Dir.mkdir(save_dir) | |
images.peach(10) do |image| | |
`wget #{image.attributes["src"].value} -O #{save_dir + Pathname.new(image.attributes["src"].value).basename.to_s}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment