Skip to content

Instantly share code, notes, and snippets.

@Veejay
Created April 23, 2010 21:38
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 Veejay/377219 to your computer and use it in GitHub Desktop.
Save Veejay/377219 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mechanize'
require 'net/http'
require 'cgi'
def get_imdb_id_from_name(name)
a = Mechanize.new
# imdb apparently searches for the ua to avoid crawling
a.user_agent_alias = 'Mac Safari'
# The URL we're retrieving the information from
s = 'http://www.imdb.com/find?s=all&q='+CGI.escape(name)
a.get(s) do |page|
a.click(page.link_with(:text => /Sean Connery/))
end
end
end
get_imdb_id_from_name("Sean Connery")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment