Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if Gem.win_platform?
- module Process
- RLIMIT_NOFILE = 7
- def self.getrlimit(*args)
- [1024]
- end
- end
- end
- require 'mechanize'
- $agent = Mechanize.new
- SaveFolder = "downloads"
- Dir.mkdir SaveFolder unless File.exist? SaveFolder
- def save_image(link, filename)
- path = "#{SaveFolder}/#{filename}"
- puts "Saving #{link} to #{path}"
- $agent.get(link).save(path)
- end
- doc = $agent.get 'https://www.deviantart.com/'
- doc.links.each do |link|
- link = link.uri.to_s
- next if link[-1] == 's'
- next unless link.include?("/art/")
- puts link
- image_page = $agent.get(link)
- title = image_page.search("._2p6cd").first.inner_text rescue nil
- if title.nil?
- puts "No title found in #{link}, skipping"
- next
- end
- title.tr!(":\\\/?!*", '')
- img_link = image_page.search("._1izoQ").first.get_attribute("src")
- save_image(img_link, "#{title}.png")
- end
Add Comment
Please, Sign In to add comment