Created
October 5, 2012 16:49
-
-
Save choipd/3840933 to your computer and use it in GitHub Desktop.
Nokogiri 사용법
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
uri = "http://www.mulga.go.kr/price/bestStore/regionInfo.do?bestStoreSeq=#{n}" | |
doc = Nokogiri::HTML(open(uri)) | |
data = GoodShop.new | |
data.crawl_no = n | |
data.title = doc.xpath("//div[attribute::id='content']/h4").text | |
data.address = doc.xpath("//th[text()='주소']/following-sibling::*").text | |
data.phone = doc.xpath("//th[text()='전화번호']/following-sibling::*").text | |
data.business_type = doc.xpath("//th[text()='업종']/following-sibling::*").text | |
a = doc.xpath("//th[text()='주요품목']/following-sibling::*").collect { |a| a.text } | |
h = Hash[*a] | |
data.items = h | |
data.remark = doc.xpath("//h5[text()='업소자랑거리']/following-sibling::*").text | |
data.save! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment