Last active
November 30, 2015 21:42
-
-
Save chuck0523/951016199bea833f52ac to your computer and use it in GitHub Desktop.
This file contains 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
require 'nokogiri' | |
require 'anemone' | |
opts = { | |
depth_limit: 1 | |
# 0 => 指定したURL先のみ | |
# 1 => 指定したURLにあるlinkから辿れる先も見る。 | |
} | |
puts "「ローソン」" | |
Anemone.crawl("http://www.lawson.co.jp/recommend/original/oden/", opts) do |anemone| | |
anemone.on_pages_like(/http:\/\/www.lawson.co.jp\/recommend\/original\/oden\//) do |page| | |
page.doc.xpath("/html//article[@id='oden']/section[@id='sec-02']/ul/li").each do |node| | |
item = node.xpath("./p[@class='ttl']/text()").to_s | |
price = node.xpath("./p[@class='price']/text()").to_s | |
puts item + "," + price + "円\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment