Skip to content

Instantly share code, notes, and snippets.

@ericjang
Last active November 7, 2015 16:15
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 ericjang/53aea0ed4943e1c5fd32 to your computer and use it in GitHub Desktop.
Save ericjang/53aea0ed4943e1c5fd32 to your computer and use it in GitHub Desktop.
Based Prison School Cover Image Download
import requests
from bs4 import BeautifulSoup
import re
for v in range(1,18): # update chapter numbers as needed
fname = 'Volume_%02d.jpg' % v
url = 'http://prison-school.wikia.com/wiki/Category:Volume_Cover_Images?file=%s' % fname
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
pattern = r'http:\/\/vignette\d.wikia.nocookie.net\/prison-school\/images\/\w*\/\w*\/' + fname + '\/revision\/latest\/'
r = re.compile(pattern)
x = soup.find("img",{"src":r})
img = r.match(x.attrs['src']).group()
print(img)
f = open(fname,'wb')
f.write(requests.get(img).content)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment