Created
January 13, 2016 01:44
-
-
Save MowAlon/1c2be1f6a04008dab0dc to your computer and use it in GitHub Desktop.
Find a dvd cover for a movie
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
# Given the name of a movie | |
# Find me the cover of | |
# Gattaca | |
# Titanic | |
# Memento | |
# if you don't have this | |
# $ gem install rest client | |
require 'rest-client' | |
require 'nokogiri' | |
['Gattaca', 'Titanic', 'Memento'].each do |movie| | |
response = RestClient.get "http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=#{movie}" | |
doc = Nokogiri::HTML(response) | |
url = doc.at_css('ul img')['src'] | |
puts "Found #{movie} at #{url}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment