Last active
November 7, 2015 16:15
-
-
Save ericjang/53aea0ed4943e1c5fd32 to your computer and use it in GitHub Desktop.
Based Prison School Cover Image 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 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