Skip to content

Instantly share code, notes, and snippets.

@t0d0r
Created December 21, 2011 22:56
Show Gist options
  • Save t0d0r/1508087 to your computer and use it in GitHub Desktop.
Save t0d0r/1508087 to your computer and use it in GitHub Desktop.
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