Created
July 8, 2014 21:08
-
-
Save wcaleb/3afca0083063b7f9ab91 to your computer and use it in GitHub Desktop.
Renaming PH2 lesson files after wget download
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
import os | |
from bs4 import BeautifulSoup | |
files = os.listdir('.') | |
for file in files: | |
html = open(file, 'r').read() | |
soup = BeautifulSoup(html) | |
url = soup.find(rel='canonical')['href'] | |
open(url.split('/')[-1] + '.html', 'w').write(html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment