Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Note: you'll need to make \ruby\img unless you're using the .bat I made
- #Images will go to \ruby\img and URLs will go to \ruby\rURLsXXX.txt, where XXX is the starting point
- require 'net/http'
- require 'uri'
- print "Start point: "
- start = gets.to_i
- print "End point: "
- finish = gets.to_i
- puts
- i = start
- while i <= finish
- #Check wallpaper main page to see if it exists
- url = "http://wallbase.cc/wallpaper/" + i.to_s
- uri = URI.parse(url)
- result = Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
- if result.code == "404"
- puts "Wallpaper " + i.to_s + " removed"
- elsif result.code == "403"
- puts "Wallpaper " + i.to_s + " hidden"
- else
- #Try to get link from page
- uris = URI.extract(result.body)
- url = (uris.find_all{ |i| i.start_with?("http://wallpapers.wallbase.cc") })[0]
- uri = URI.parse(url)
- result = Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
- if (result.code != "404" && result.code != "403")
- uri = URI.parse(url).to_s
- File.open(Dir.pwd + "/img/" + File.basename(uri),'wb'){ |f| f.write(result.body) }
- File.open("rURLs" + start.to_s + ".txt", 'a') { |f| f.puts(url) }
- puts "Found: " + url
- else
- puts "Error: bad link " + i.to_s
- File.open("Errors" + start.to_s + ".txt", 'a') { |f| f.puts(i) }
- end
- end #end if (wallpaper exists)
- i+=1
- end
- puts "All Done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement