Skip to content

Instantly share code, notes, and snippets.

@Coro365
Created November 10, 2017 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coro365/1aee403748bc00493d03e6a7fab1dfba to your computer and use it in GitHub Desktop.
Save Coro365/1aee403748bc00493d03e6a7fab1dfba to your computer and use it in GitHub Desktop.
watch anime count in animetick.net
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