11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/www/video_scraper/tube8.rb', line 11
def scrape
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['videoUrl'][0]
uri = URI.parse(@page_url)
@thumb_url = URI.join("#{uri.scheme}://#{uri.host}", flashvars['imageUrl'][0]).to_s
@title = doc.at('//h1[@class="text"]').inner_html rescue nil
doc.search('//a').each do |elem|
if href = elem.attributes['href']
if href.match(/\.3gp$/)
@video_url_3gp = href
break
end
end
end
end
|