Skip to content

Instantly share code, notes, and snippets.

Created Jan 8, 2017
What would you like to do?
# -- coding: utf-8
require "open-uri"
require "rubygems"
require "nokogiri"
url = ""
charset = nil
html = open(url) do |f|
  charset = f.charset
doc = Nokogiri::HTML.parse(html, nil, charset)
# doc.xpath("<xpathで指定したい場所>"
# doc.css("<cssで指定したい場所>")
p doc.xpath("//html/body/div[3]/div[2]/div/div[1]/h3").text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment