Last active
August 29, 2015 14:21
-
-
Save 844196/e2b074d493cd5d483e7d 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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'nokogiri' | |
require 'optparse' | |
options = ARGV.getopts('n') | |
url = 'https://docs.google.com/spreadsheets/d/18s122iy_F8RgivDzF6BE6fL-nuHyOql5lZ3E_qeA1Dw/pubhtml?gid=1701793155&single=true' | |
charset = nil | |
html = open(url) do |f| | |
charset = f.charset | |
f.read | |
end | |
doc = Nokogiri::HTML.parse(html, nil, charset) | |
html = doc.xpath('/html/body') | |
array = [] | |
html.css('tbody tr').each do |tr| | |
next if tr.css('td')[1].nil? | |
no = tr.css('td')[0].text | |
date = tr.css('td')[1].text | |
author = tr.css('td')[2].text | |
page_title = tr.css('td')[3].text | |
page_url = tr.css('td')[4].text | |
array << [no, date, author, page_title, page_url] | |
end | |
if options['n'] | |
array.each do |a| | |
next if a[4].empty? | |
puts a.join("\t") | |
end | |
else | |
array.each {|a| puts a.join("\t") } | |
end |
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
# インタラクティブに記事を検索して記事を開く | |
$ oac2014.rb -n | column -t -s " " | peco | sed -e 's/.*\(http.*\)$/\1/g' | xargs chromium >/dev/null 2>&1 | |
# ユーザーの執筆回数を求める | |
$ oac2014.rb -n | awk 'NR>1{print$3}' | sort | uniq -c | sort -r | |
47 はちよん | |
20 ひげ | |
5 おさむ | |
3 ヒョウシキノグチ | |
3 ノグチ | |
2 屯ちゃん | |
2 ヒョウシキノグチ | |
1 標識 | |
1 同上 | |
1 (匿名希望) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment