Created
December 21, 2011 22:56
-
-
Save t0d0r/1508087 to your computer and use it in GitHub Desktop.
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 'open-uri' | |
| require 'nokogiri' | |
| require 'erb' | |
| include ERB::Util | |
| q=url_encode("site:shipspotting.com 7811032 IMO") | |
| doc = Nokogiri::HTML(open("http://www.google.com/search?q=#{q}")) | |
| link = doc.css("h3.r > a").first | |
| url = link['href'] | |
| doc = Nokogiri::HTML(open(url)) | |
| dom4img = "div.content > center > table > tr > td > center > img" | |
| img = doc.css(dom4img).first | |
| puts img['src'] | |
| puts img['title'] | |
| dom4shipdata = "html > body > center > table > tr > td > table > tr > td > div.content > center > table > tr > td > table > tr > td.whiteboxstroke" | |
| puts doc.css(dom4shipdata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment