Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created September 18, 2011 10:03
Show Gist options
  • Select an option

  • Save 3dd13/1224940 to your computer and use it in GitHub Desktop.

Select an option

Save 3dd13/1224940 to your computer and use it in GitHub Desktop.

Revisions

  1. 3dd13 revised this gist Sep 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion apple_green_address.rb
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # install it if you haven't done it:
    # sudo gem install mechanize
    #
    require mechanize
    require 'mechanize'

    agent = Mechanize.new
    page = agent.get("http://www.openrice.com/english/restaurant/sr2.htm?shopid=32108")
  2. 3dd13 created this gist Sep 18, 2011.
    16 changes: 16 additions & 0 deletions apple_green_address.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #
    # 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