Created
August 5, 2017 10:33
-
-
Save felinebabies/7b91b2c31b8eebae5b314f217729f7eb to your computer and use it in GitHub 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
| # coding: utf-8 | |
| require "nokogiri" | |
| require "open-uri" | |
| require "uri" | |
| INDEXPAGEURL = "http://illustrain.com/?cat=19" | |
| SAVEDIR = "./download" | |
| html = open(INDEXPAGEURL).read | |
| doc = Nokogiri::HTML(html, INDEXPAGEURL) | |
| puts doc.title | |
| pagelistarr = doc.css(".thumb-post-lists li a").map do |item| | |
| item.attr("href") | |
| end | |
| puts pagelistarr | |
| pagelistarr.each do |url| | |
| html = open(url).read | |
| doc = Nokogiri::HTML(html, url) | |
| illusturl = doc.css(".bt-download a").attr("href") | |
| illustdata = open(illusturl).read | |
| filename = File.basename(illusturl) | |
| savepath = File.join(SAVEDIR, filename) | |
| open(savepath, "w+b") do |out| | |
| out.write(illustdata) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment