forked from maddox/imdb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
49 lines (39 loc) · 3.07 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
A simple ruby library to scrape IMDB
FORK:
This project was forked at the RubyJax May 2009 "Pair Programming" meeting as
an experiment to see if we could add search.
Thanks to my pair Imre Mehesz, you can now search for a movie.
__Demo__
>> require 'lib/imdb'
>> movies = Imdb.find_movie_by_name("The Godfather")
=> [#<Imdb::SearchResult:0x53ceb0 @id="tt0068646", @name="The Godfather (1972) aka \"Mario Puzo's The Godfather\" - USA (complete title)", @url="http://imdb.com/title/tt0068646/">, #<Imdb::SearchResult:0x51adb0 @id="tt0071562", @name="The Godfather: Part II (1974) aka \"Mario Puzo's The Godfather: Part II\" - USA (complete title)aka \"The Second Godfather\" - USA (working title)", @url="http://imdb.com/title/tt0071562/">, #<Imdb::SearchResult:0x507e68 @id="tt0099674", @name="The Godfather: Part III (1990) aka \"Mario Puzo's The Godfather: Part III\" - USA (complete title)", @url="http://imdb.com/title/tt0099674/">]
>> movies.last.name
=> "The Godfather: Part III (1990) aka "Mario Puzo's The Godfather: Part III" - USA (complete title)"
>> movies.last.url
=> "http://imdb.com/title/tt0099674/"
>> movies.last.id
=> "tt0099674"
>> Imdb.find_movie_by_id(movies.last.id)
=> #<ImdbMovie:0x11e45b4 @rating="7.6", @tagline="All the power on earth can't change destiny.", @writers=[#<ImdbName:0x68f88 @name="Mario Puzo", @imdb_id="nm0701374", @role="written by">, #<ImdbName:0x68dd0 @name="Francis Ford Coppola", @imdb_id="nm0000338", @role="written by">], runtime"162 min | USA:169 min (video version)", title"The Godfather: Part III", release_date#<Date: 4896501/2,0,2299161, @imdb_id="tt0099674", @plot="In the midst of trying to legitimize his business dealings in 1979 New York and Italy, aging mafia don Michael Corleone seeks to vow for his sins while taking a young prot\351g\351 under his wing.", @genres=[#<ImdbGenre:0x425b8 @name="Action", @imdb_id="Action">, #<ImdbGenre:0x4176c @name="Crime", @imdb_id="Crime">, #<ImdbGenre:0x41370 @name="Drama", @imdb_id="Drama">, #<ImdbGenre:0x4095c @name="Thriller", @imdb_id="Thriller">], poster_url"http://ia.media-imdb.com/images/M/MV5BMTc3NzQ5ODYyMF5BMl5BanBnXkFtZTcwNDc1NzgyMQ@@._V1._SX98_SY140_.jpg", company#<ImdbCompany:0x119c55c @name="Paramount Pictures", @imdb_id="co0023400">, directors[#<ImdbName:0x6fff4 @name="Francis Ford Coppola", @imdb_id="nm0000338", @role=nil>]
USAGE:
require 'Imdb'
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/