Sha256: aa2023a0b389a1d8b770a3595299fda22380d35a85682dc279783ba9bda430e7
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
require 'rmd/nct/getter/base' module RMD module NCT module Getter class KeyFromPage < Base def fetch if key && element @data_link = element.text.strip else @errors = "The page does not contain the key." end end private def uncached_key page.search('script').each do |element| if match_data = regex.match(element.text) return match_data.to_a.last end end nil end def new_link "http://www.nhaccuatui.com/flash/xml?key1=#{key}" end def page @page ||= agent.get(url) end def new_page @new_page ||= agent.get(new_link) end def response @response ||= Nokogiri::XML(new_page.body) end def element @element ||= response.at_xpath('.//tracklist//location') end def regex /NCTNowPlaying.intFlashPlayer\("flashPlayer", "song", "(.+)"\)\;/ end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rmd-0.2.1 | lib/rmd/nct/getter/key_from_page.rb |
rmd-0.1.2 | lib/rmd/nct/getter/key_from_page.rb |
rmd-0.1.1 | lib/rmd/nct/getter/key_from_page.rb |
rmd-0.1.0 | lib/rmd/nct/getter/key_from_page.rb |