Skip to content

Instantly share code, notes, and snippets.

@complexsplit
Last active December 25, 2015 17:59
Show Gist options
  • Save complexsplit/7017313 to your computer and use it in GitHub Desktop.
Save complexsplit/7017313 to your computer and use it in GitHub Desktop.
Downloading VMworld content
require 'rubygems'
require 'watir-webdriver'
require 'open-uri'
$sessionurls = Array.new
browser = Watir::Browser.new
browser.goto 'http://www.vmworld.com/community/sessions/2013/'
browser.link(:text =>"Sign In").when_present.click
browser.text_field(:name => 'username').set 'your_username'
browser.text_field(:name => 'password').set 'your_password'
browser.button(:name => 'login').click
browser.links.each do |link|
if link.href.to_s.include? "DOC-"
$sessionurls << link.href
end
end
$sessionurls.each do |sessurl|
browser.goto sessurl
browser.links.each do |slink|
if slink.href.to_s.include? "classID"
slink.fire_event('onclick')
end
end
sleep 1
browser.frame(:id => 'session').links.each do |media|
if (media.href.include? "mp3") || (media.href.include? "pdf")
base = File.basename(media.href.to_s)
open(base, 'wb', :read_timeout=>nil) do |file|
file << open(media.href).read
end
end
end
mp4url = browser.frame(:id => 'session').frames[0].video.source.src
base = File.basename(mp4url)
open(base, 'wb', :read_timeout=>nil) do |file|
file << open(mp4url).read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment