Created
March 9, 2012 19:47
-
-
Save samrat/2008307 to your computer and use it in GitHub Desktop.
xtremepapers.py
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
| """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