Sha256: ff4c7e04b54e64ff9b512c3d832337d322d7c4058fa19b7cd81f8ed6e73c0354
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
class MovieHelper::Scraper def self.scrape_movie(link, category) doc = Nokogiri::HTML(open(link)) hash = {} hash[:title] = doc.css("span.content-title").children.text.strip hash[:year] = doc.css("span.single-year").children.text.strip hash[:summary] = doc.css("div.wc-comment-text").children.text.strip hash[:genre] = doc.css("span[itemprop='genre']").children.text.strip if doc.css("div.infom span").count > 1 hash[:mood] = doc.css("div.infom span")[1].text.strip hash[:actors] = doc.css("div.infom span")[2].text.strip hash[:director] = doc.css("div.infom span")[3].text.strip hash[:language] = doc.css("div.infom span")[4].text.strip end hash[:url] = link if category == "netflix" hash[:is_netflix] = true elsif category == "amazon" hash[:is_amazon] = true elsif category == "elsewhere" hash[:is_elsewhere] = true end hash end def self.random scrape_movie("https://agoodmovietowatch.com/random/", nil) end def self.latest_netflix doc = Nokogiri::HTML(open("https://agoodmovietowatch.com/all/?on=USA-netflix&by=new")) links = doc.css("span.content-title").map {|movie| movie.css("a").first.first.last} best = links.map {|movie_link| scrape_movie(movie_link, "netflix")} end def self.latest_amazon doc = Nokogiri::HTML(open("https://agoodmovietowatch.com/all/?on=USA-amazon-prime&by=new")) links = doc.css("span.content-title").map {|movie| movie.css("a").first.first.last} best = links.map {|movie_link| scrape_movie(movie_link, "amazon")} end def self.latest_elsewhere doc = Nokogiri::HTML(open("https://agoodmovietowatch.com/all/?by=new")) links = doc.css("span.content-title").map {|movie| movie.css("a").first.first.last} best = links.map {|movie_link| scrape_movie(movie_link, "elsewhere")} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
movie_helper-0.2.0 | lib/movie_helper/scraper.rb |