Skip to content

Instantly share code, notes, and snippets.

@shirayuca
Last active August 29, 2015 14:12
Show Gist options
  • Save shirayuca/95efa71b32e0f8383baf to your computer and use it in GitHub Desktop.
Save shirayuca/95efa71b32e0f8383baf to your computer and use it in GitHub Desktop.
vorkers_list_repeat.rb
http://www.vorkers.com/field.php?ind_code=0003&f_code=0025
http://www.vorkers.com/field.php?next_page=2&ind_code=0003&f_code=0025
http://www.vorkers.com/field.php?next_page=3&ind_code=0003&f_code=0025
require 'open-uri'
require 'nokogiri'
def getList(gyokai_url)
charset = nil
html = open(gyokai_url) do |f|
charset = f.charset # 文字種別を取得
f.read # htmlを読み込んで変数htmlに渡す
end
# htmlをパース(解析)してオブジェクトを作成
doc = Nokogiri::HTML.parse(html, nil, charset)
doc.xpath('//tr').each_with_index do |node,index|
if index == 0
next
end
puts [
node.xpath('.//td[@class="comp_name"]').text,
node.xpath('.//td[@class="comp_name"]/a').attribute('href').value,
node.xpath('.//td[@class="num_answer"]').text,
node.xpath('.//td[@class="total_score"]/span[@class="score_up"]').text
].join(',')
end
end
open('pagelist.txt').each do |line|
p line.chomp!
getList(line)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment