imdb: A simple ruby library to scrape IMDB
or, using Nokogiri to account for IMDB’s utter lack of an API
New Style usage is pretty close to Old Skool; mostly, it’s just a shift to the preferred Ruby subclass idiom of IMDB::Movie (rather than ImdbMovie). Also, `imdb_id` is now `id` and `type` returns something meaningful.
require 'imdb'
movie = IMDB::Movie.find_by_id('tt1099212')
puts "IMDB ID: #{movie.id}"
puts "Title: #{movie.title}"
puts "Rating: #{movie.rating}"
puts "Release Date: #{movie.release_date}"
puts "Tagline: #{movie.tagline}"
puts "Plot: #{movie.plot}"
puts "Runtime: #{movie.runtime}"
movie.directors.each do |director|
puts "Director: #{director.name}"
end
movie.writers.each do |writer|
puts "Writer: #{writer.name}"
end
movie.genres.each do |genre|
puts "Genre: #{genre.name}"
end
puts "Poster URL: #{movie.poster_url}"
require 'imdb'
require 'imdb/old_skool_compatibility'
movie = Imdb.find_movie_by_id('tt1099212')
puts "IMDB ID: #{movie.imdb_id}"
puts "Title: #{movie.title}"
puts "Rating: #{movie.rating}"
puts "Release Date: #{movie.release_date}"
puts "Tagline: #{movie.tagline}"
puts "Plot: #{movie.plot}"
puts "Runtime: #{movie.runtime}"
movie.directors.each do |director|
puts "Director: #{director.name}"
end
movie.writers.each do |writer|
puts "Writer: #{writer.name}"
end
movie.genres.each do |genre|
puts "Genre: #{genre.name}"
end
puts "Poster URL: #{movie.poster_url}"
Thats about all it does. its simple. I only made it to work with another project.
Thanks to ‘We <} Code’ for the jump start via http://www.weheartcode.com/2007/04/03/scraping-imdb-with-ruby-and-hpricot/