Created
April 29, 2017 12:44
-
-
Save arafsheikh/1171563aed7620b044150e5774a8c418 to your computer and use it in GitHub Desktop.
Download all PDF files in a webpage
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 mechanize import Browser | |
from bs4 import BeautifulSoup | |
URL = "" | |
br = Browser() | |
res = br.open(URL) | |
soup = BeautifulSoup(res.read()) | |
a = soup.find_all('a') | |
for link in a: | |
link = link['href'] | |
if '.pdf' in link: | |
urllib.urlretrieve(link, "Lesson " + count) | |
count += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment