Last active
December 30, 2015 22:18
-
-
Save daisy1754/7892810 to your computer and use it in GitHub Desktop.
UIFacesから顔画像をダウンロードする
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
require "httparty" | |
require "nokogiri" | |
response = HTTParty::get('http://uifaces.com/authorized') | |
doc = Nokogiri::HTML.parse(response.body, nil, nil) | |
faces = doc.xpath('//*[@id="app"]/div[2]/div/div/div/a') | |
names = [] | |
faces.each do |face| | |
name = face.attributes['title'].value.sub('@', '') | |
url = face.attributes['data-source'].value | |
sleep(1) | |
File.open("#{name}.jpg", "w") do |file| | |
file.write HTTParty.get(url).body | |
end | |
names << name | |
end | |
p names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment