Skip to content

Instantly share code, notes, and snippets.

@hails
Last active August 29, 2015 14:18
Show Gist options
  • Save hails/a4e46882fcaa7f01d66e to your computer and use it in GitHub Desktop.
Save hails/a4e46882fcaa7f01d66e to your computer and use it in GitHub Desktop.
Script to download all screencast files from elixirsips.com (an account is required)
require 'rubygems'
require 'mechanize'
domain = 'https://elixirsips.dpdcart.com'
agent = Mechanize.new
agent.pluggable_parser.default = Mechanize::Download
folder = 'PATH/TO/FOLDER'
page = agent.get('https://elixirsips.dpdcart.com/subscriber/content')
pageform = page.form()
pageform.username = 'YOUR EMAIL'
pageform.password = 'YOUR PASSWORD'
page = agent.submit(pageform, pageform.buttons.first)
# sort by `older to newer` (i.e.: 001_, 002_, ...)
page = page.links_with(text: 'Read More').each.sort_by {|elem| elem.href}
page.each do |link|
content_page = link.click
content_page.links_with(href: /subscriber\/download.*/).each do |item|
download_link = domain + item.href
filename = File.join(folder, item.text)
unless File.exist?(filename)
puts "Downloading: #{item.text}"
agent.get(download_link).save(filename)
end
end
end
@hails
Copy link
Author

hails commented Apr 10, 2015

Install mechanize with:
gem install mechanize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment