Skip to content

Instantly share code, notes, and snippets.

@wreulicke
Last active May 3, 2016 03:43
Show Gist options
  • Save wreulicke/550d4bb3a93754b73ade7a4d012cf408 to your computer and use it in GitHub Desktop.
Save wreulicke/550d4bb3a93754b73ade7a4d012cf408 to your computer and use it in GitHub Desktop.
Nokogiriしたのでメモ

nokogiri test

require 'open-uri'
require 'nokogiri'
require "kconv"

url = 'http://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/toukei_hatubaibi.php'
def p (*str)
  print str.join(", ")+"\r\n"
end
charset = nil
html = open(url) do |f|
  charset = f.charset
  f.read
end

doc = Nokogiri::HTML.parse(html, nil, charset)
doc.xpath('//table/tbody/tr/td/table/tbody/tr/td[1]/a').each do |node|
  p URI.join(url,"./",node[:href]), node.inner_text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment