Download wallpapers from

From CodeCodex

Save it as a file.rb and run it as ruby file.rb url

require 'rubygems'
require 'mechanize'

=begin wallpaper scrapper:
	You provide it with the URL on the command line such as<model_name>/wallpapers/
	and it automatically downloads the wallpapers with the highest resolution from every available page.
	Written by an annonymous noob programmer.
	I hope this helps you as much as it helped me learn Ruby, Xpath and WWW::Mechanize.

agent =
agent.user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.8 (KHTML, like Gecko) Chrome/ Safari/532.8"
mainpage = agent.get ARGV[0]
pages = {mainpage.uri => mainpage}"//div[@id='pagination']/a").each do |a|
	page = agent.get a['href']
	if !pages.has_key?(page.uri) then pages[page.uri] = page end
puts "We have #{pages.size} pages to parse"
pages.each do |k,page|
	puts ""
	puts "Next page: #{k}""//ul[@class='resolutionListing']/li[last()]/a").each do |anchor|
		imagepage = agent.get anchor['href']"//img[@id='wallpaper_image']").each do |image|
			puts "Saving image: #{image['src']}"
puts "Finished!"