Class: WWW::VideoScraper::EicBook
- Defined in:
- lib/www/video_scraper/eic_book.rb
Instance Attribute Summary collapse
-
#capture_urls ⇒ Object
readonly
Returns the value of attribute capture_urls.
Attributes inherited from Base
#embed_tag, #page_url, #thumb_url, #title, #video_url
Instance Method Summary collapse
Methods inherited from Base
#initialize, scrape, url_regex, valid_url?
Constructor Details
This class inherits a constructor from WWW::VideoScraper::Base
Instance Attribute Details
#capture_urls ⇒ Object (readonly)
Returns the value of attribute capture_urls.
8 9 10 |
# File 'lib/www/video_scraper/eic_book.rb', line 8 def capture_urls @capture_urls end |
Instance Method Details
#scrape ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/www/video_scraper/eic_book.rb', line 11 def scrape uri = URI.parse(@page_url) @page_url = "#{uri.scheme}://#{uri.host}#{uri.path}?flg=sm" html = http_get(@page_url) doc = Hpricot(html.toutf8) raise FileNotFound unless flashvars = doc.at('//object //param[@name="FlashVars"]') flashvars = CGI.parse(flashvars.attributes['value']) @video_url = flashvars['flv'][0] @title = CGI.unescapeHTML(doc.at('//h2[@class="detailTtl"]').inner_html).gsub(' ', ' ') rescue nil html = http_get("#{uri.scheme}://#{uri.host}#{uri.path}?flg=h4") doc = Hpricot(html.toutf8) if img = doc.at('//div[@class="detailMN"]/img[@class="waku01"]') @thumb_url = URI.join("#{uri.scheme}://#{uri.host}", img.attributes['src']).to_s end html = http_get("#{uri.scheme}://#{uri.host}#{uri.path}?flg=cp") doc = Hpricot(html.toutf8) @capture_urls = [] doc.search('//div[@class="detailMN"]/img[@class="waku01"]') do |img| @capture_urls << URI.join("#{uri.scheme}://#{uri.host}", img.attributes['src']).to_s end end |