Skip to content

Instantly share code, notes, and snippets.

@samrat
Created March 9, 2012 19:47
Show Gist options
  • Save samrat/2008307 to your computer and use it in GitHub Desktop.
Save samrat/2008307 to your computer and use it in GitHub Desktop.
xtremepapers.py
"""Downloads all .pdf files when given a URL
"""
from bs4 import BeautifulSoup
import requests
import os
url = \
"http://www.xtremepapers.com/papers/CIE/Cambridge%20International%20A%20and%20AS%20Level/Mathematics%20-%20Further%20(9231)/"
r = requests.get(url).text
soup = BeautifulSoup(r)
for link in soup.find_all('a', attrs={'class':'autoindex_a'}):
if link.get('href')[-3: len(link.get('href'))] == 'pdf':
file_url= url + link.get('href')
os.system('wget -c ' + file_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment