Skip to content

Commit

Permalink
Ignore DVDs
Browse files Browse the repository at this point in the history
  • Loading branch information
leereilly committed Jan 13, 2020
1 parent cb576b4 commit d8e088c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion poster.rb
@@ -1,6 +1,12 @@
require 'nokogiri'
require 'open-uri'

def download_image(url, dest)
open(url) do |u|
File.open(dest, 'wb') { |f| f.write(u.read) }
end
end

posters = Array.new
url = 'https://www.joblo.com/movie-posters'
doc = Nokogiri::HTML(open(url))
Expand All @@ -14,5 +20,13 @@
# https://www.joblo.com/assets/images/joblo/posters/2020/01/birdspreyhyenaman.jpg

posters.each do |poster|
puts 'https://www.joblo.com/' + poster.gsub("_thumb", "") if poster.include? 'thumb'
if (poster.include? 'thumb') && (poster.include? 'poster')
image_url = 'https://www.joblo.com/' + poster.gsub("_thumb", "")
filename = "posters/" + File.basename(image_url)

open(filename, 'wb') do |file|
puts "Writing #{image_url} to #{filename}"
file << open(image_url).read
end
end
end

0 comments on commit d8e088c

Please sign in to comment.