Skip to content

Instantly share code, notes, and snippets.

@wcaleb
Created July 8, 2014 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcaleb/3afca0083063b7f9ab91 to your computer and use it in GitHub Desktop.
Save wcaleb/3afca0083063b7f9ab91 to your computer and use it in GitHub Desktop.
Renaming PH2 lesson files after wget download
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