Created
April 23, 2010 21:38
-
-
Save Veejay/377219 to your computer and use it in GitHub Desktop.
This file contains 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 '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