Last active
November 1, 2020 21:32
-
-
Save danielglh/8f4d4e7bca4975aa9b85cd1957eaaca4 to your computer and use it in GitHub Desktop.
Download All Free PragPub Magazines
This file contains hidden or 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
# PragPub magazines offer the first 49 issues for free here: https://pragprog.com/magazines. | |
# This script allows you to download all these free issues. | |
# For newer issues, you have to purchase them here: http://theprosegarden.com/. | |
require 'open-uri' | |
require 'open_uri_redirections' | |
def download_issue(num) | |
num = num.to_s.rjust(3, "0") | |
dir = "issue.#{num}" | |
Dir.mkdir(dir) unless File.exists?(dir) | |
%w(pdf html mobi epub).each do |ext| | |
url = "https://pragprog.com/magazines/download/#{num}.#{ext}" | |
open("#{dir}/pragpub_#{num}.#{ext}", 'wb') do |file| | |
file << open(url, allow_redirections: :all).read | |
end | |
end | |
end | |
(1..49).each {|i| download_issue(i)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! Looks like the urls have changed, and I don't think html versions are available anymore, but I made some changes that did the trick for me (along with changing the local dir structure for my own purposes):