Created
September 18, 2011 10:03
-
-
Save 3dd13/1224940 to your computer and use it in GitHub Desktop.
Scraping the address of "Apple Green" from openrice.com
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
# | |
# loading the mechanize library for scraping | |
# install it if you haven't done it: | |
# sudo gem install mechanize | |
# | |
require 'mechanize' | |
agent = Mechanize.new | |
page = agent.get("http://www.openrice.com/english/restaurant/sr2.htm?shopid=32108") | |
# | |
# use the css selector to identify the address HTML tag element | |
# specify [2] because the address stays in the third td tag element | |
# | |
address_element = page.search("table.addetail tbody tr td div table tbody tr td")[2] | |
puts address_element.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment