Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Last active November 30, 2015 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/951016199bea833f52ac to your computer and use it in GitHub Desktop.
Save chuck0523/951016199bea833f52ac to your computer and use it in GitHub Desktop.
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