Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created September 18, 2011 10:03
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 3dd13/1224940 to your computer and use it in GitHub Desktop.
Save 3dd13/1224940 to your computer and use it in GitHub Desktop.
Scraping the address of "Apple Green" from openrice.com
#
# 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