-
-
Save ai-ml-architect/8e47e0e3cf97d3421ab5ad733fa38200 to your computer and use it in GitHub Desktop.
Behance Project Images downloader
`ruby app.rb http://www.behance.net/gallery/Web-SPIT-Mx/10331815 ~/Desktop`
This file contains hidden or 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
| require 'nokogiri' | |
| require 'open-uri' | |
| class ImageFetcher | |
| EXCLUDES = [ | |
| "http://a2.behance.net/img/site/grey.png" | |
| ] | |
| def self.get_all_img_src(url) | |
| doc = Nokogiri::HTML(open(url)) | |
| imgs = doc.css('.module img').map do |img| | |
| img.attributes['src'].value | |
| end | |
| return imgs - EXCLUDES | |
| end | |
| end | |
| ## Begin Main App | |
| url = ARGV[0] | |
| dir_path = ARGV[1] || "projects" | |
| puts "Begin Download" | |
| imgs = ImageFetcher.get_all_img_src(url) | |
| puts "Create Folder" | |
| project_path = File.join [dir_path, url.split('/')[-2]] | |
| [dir_path, project_path].each do |dir| | |
| Dir.mkdir(dir) unless File.exists?(dir) | |
| end | |
| puts "Downloading Images" | |
| imgs.each do |img| | |
| file_name = img.split('/').last | |
| file_path = File.join([project_path, file_name]) | |
| content = open(img).read | |
| File.write(file_path, content) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.behance.net/gallery/115532245/Responsive-Anime-Website-Design-Concept?tracking_source=search_projects_recommended%7Canime%20website