Created
November 10, 2017 17:02
-
-
Save Coro365/1aee403748bc00493d03e6a7fab1dfba to your computer and use it in GitHub Desktop.
watch anime count in animetick.net
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 "pp" | |
require "open-uri" | |
require "nokogiri" | |
@userid = "Coro365" | |
@crawl_page_number = 26 | |
@animetick_subscribes = Array.new | |
def animetick_crawl(page_number) | |
url = "http://animetick.net/users/#{@userid}?page=#{page_number}" | |
begin | |
atick = Nokogiri::HTML.parse(open(url),nil,"utf-8") | |
rescue Exception => e | |
puts "#{e.message} #{url}" | |
end | |
atick.xpath("//li[@class='animation']").each do |i| | |
imgurl = i.xpath("div[@class='icon']/img").attribute("src").value | |
title = i.xpath("div[@class='detail']").attribute("title").value | |
tid = imgurl.slice(6..9).delete("_") | |
title.slice!(/\(第[0-9]*?クール\)/) | |
@animetick_subscribes.push([title, tid]) | |
end | |
end | |
@crawl_page_number.times do |i| | |
animetick_crawl(i) | |
end | |
pp @animetick_subscribes.uniq! | |
puts "" | |
puts "Watched #{@animetick_subscribes.size} animes!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment