Created
August 28, 2017 21:02
-
-
Save n0mn0m/565bb31c486076a906adf45acd6500f3 to your computer and use it in GitHub Desktop.
Quick script to parse an HTML page and extract zip files.
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 bs4 import BeautifulSoup | |
from urllib.request import urlopen | |
import requests | |
import zipfile | |
import io | |
""" | |
Fails file extraction requires a password :( | |
""" | |
home = 'http://www.dndjunkie.com' | |
url = 'http://www.dndjunkie.com/rpgx/datasets/' | |
data = urlopen(url).read() | |
page = BeautifulSoup(data,'html.parser') | |
files = [] | |
for link in page.findAll('a'): | |
l = link.get('href') | |
files.append(l) | |
for l in files[2:]: | |
full_path = home + l | |
r = requests.get(full_path) | |
z = zipfile.ZipFile(io.BytesIO(r.content)) | |
z.extractall() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment