#!/usr/local/bin/ruby #hatena_counter.rb require 'open-uri' require "pp" require 'uri' text = <<"EOS" 2006年09月の人気記事 - はてな匿名ダイアリー

2006年09月の人気記事

2017010203040506070809
2016010203040506070809101112
2015010203040506070809101112
2014010203040506070809101112
2013010203040506070809101112
2012010203040506070809101112
2011010203040506070809101112
2010010203040506070809101112
2009010203040506070809101112
2008010203040506070809101112
2007010203040506070809101112
200609101112
アーカイブ ヘルプ
ログイン ユーザー登録
ようこそ ゲスト さん
EOS =begin target_date = [] urls = ["https://anond.hatelabo.jp/archive/200609"] urls.each do |url| OpenURI.open_uri(url).each_line do |html| new_line_has_been_html = html.gsub(/
  • /, "\n
  • ") new_line_has_been_html.each_line do |line| if line =~ %r|
  • .+| target_date << line.slice(%r|
  • .+|, 1) end end end end =end #url = 'http://mukar.com/test.cgi?cont=日本語テスト ホゲホゲ' #url_escape = URI.escape(url) #puts url_escape #=> http://mukar.com/test.cgi?cont=%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%86%E3%82%B9%E3%83%88%20%E3%83%9B%E3%82%B2%E3%83%9B%E3%82%B2 #puts URI.unescape(url_escape) #=>http://mukar.com/test.cgi?cont=日本語テスト ホゲホゲ target_date = [] text.each_line do |html| html.gsub(/
  • /, "\n
  • ").each_line do |line| target_date << line.slice(%r|
  • (.+) .+ (.+)|, 2) if line =~ %r|a href=""/2\d+">.+| # target_date << line.slice(%r|="(/2\d+)">(.+).+