Created
July 3, 2014 16:20
-
-
Save cheeming/a0215e7537d433b4a323 to your computer and use it in GitHub Desktop.
Download All Hacker Monthly Issues
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
from BeautifulSoup import BeautifulSoup | |
from urllib2 import build_opener | |
from os import path | |
HMSUB_SESSION_COOKIE = 'XXX' | |
o = build_opener() | |
o.addheaders.append( | |
('Cookie', '_hmsub_session=%s' % HMSUB_SESSION_COOKIE), | |
) | |
base_url = 'https://subscriber.hackermonthly.com' | |
html = o.open('%s/profile/issues' % base_url).read() | |
soup = BeautifulSoup(html) | |
for link in soup.findAll('a'): | |
href = link.get('href') | |
if href.startswith('/static'): | |
with open(path.basename(href), 'w') as f: | |
f.write(o.open('%s%s' % (base_url, href)).read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just signed up to Hacker Monthly and I was lazy to download everything manually. So here's a script that does it for me.