Skip to content

Instantly share code, notes, and snippets.

@n0mn0m
Created August 28, 2017 21:02
Show Gist options
  • Save n0mn0m/565bb31c486076a906adf45acd6500f3 to your computer and use it in GitHub Desktop.
Save n0mn0m/565bb31c486076a906adf45acd6500f3 to your computer and use it in GitHub Desktop.
Quick script to parse an HTML page and extract zip files.
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