Sha256: fe56536e8236d6a9bf65849f66d5ae1cab7c13e14ac3222b162b8ac85b6eeb6b
Contents?: true
Size: 973 Bytes
Versions: 4
Compression:
Stored size: 973 Bytes
Contents
#! /usr/bin/env ruby require 'rubygems' require 'nokogiri' require 'open-uri' # frozen_string_literal: true require 'http' require 'json' module Movlog # Service for all OMDB API calls class OmdbApi OMDB_URL = 'http://www.omdbapi.com/' def self.movie_info(t) movie_response = HTTP.get( OMDB_URL, params: { t: t, y: '', plot: 'short', r: 'json' } ) JSON.load(movie_response.to_s) end def self.location(l) movie_id = l page_url = "http://www.imdb.com/title/tt1211837/locations?ref_=tt_dt_dt" # Fetch and parse HTML document location_arr = [] doc = Nokogiri::HTML(open(page_url)) doc.search('//div[@class="soda sodavote odd"]/dt/a').each { |link| location_arr << link.content} doc.search('//div[@class="soda sodavote even"]/dt/a').each { |link| location_arr << link.content} location_arr.to_json end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
movlog-0.2.10 | lib/movlog/omdb_api.rb |
movlog-0.2.9 | lib/movlog/omdb_api.rb |
movlog-0.2.8 | lib/movlog/omdb_api.rb |
movlog-0.2.7 | lib/movlog/omdb_api.rb |