Skip to content

Instantly share code, notes, and snippets.

@MowAlon
Created January 13, 2016 01:44
Show Gist options
  • Save MowAlon/1c2be1f6a04008dab0dc to your computer and use it in GitHub Desktop.
Save MowAlon/1c2be1f6a04008dab0dc to your computer and use it in GitHub Desktop.
Find a dvd cover for a movie
# 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