Last active
August 29, 2015 14:18
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install mechanize with:
gem install mechanize