Skip to content

Instantly share code, notes, and snippets.

@cheeming
Created July 3, 2014 16:20
Show Gist options
  • Save cheeming/a0215e7537d433b4a323 to your computer and use it in GitHub Desktop.
Save cheeming/a0215e7537d433b4a323 to your computer and use it in GitHub Desktop.
Download All Hacker Monthly Issues
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())
@cheeming
Copy link
Author

cheeming commented Jul 3, 2014

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.

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