Created
August 9, 2012 02:52
-
-
Save naoranger/3300490 to your computer and use it in GitHub Desktop.
nokogiri sample tenki
This file contains hidden or 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 'open-uri' | |
| url = "http://tenki.jp/" | |
| doc = Nokogiri::HTML(open(url).read) | |
| doc.xpath('//ul[@class="localList"]//li').each do |item| | |
| # u = item.xpath('.//a').attribute('href') | |
| puts item.xpath('.//a').text | |
| # puts item.xpath('.//a/attribute::href').first | |
| # puts item.search('a').attribute('href') | |
| # doc2 = Nokogiri::HTML(open(url+u).read) | |
| # doc2.xpath('//div[@id="weatherWaveBox"]//li').each do |item2| | |
| # puts item2.xpath('.//a').text | |
| # end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment