Check in inital version of downloader
This commit is contained in:
commit
0db066c9b9
1 changed files with 30 additions and 0 deletions
30
cah.py
Executable file
30
cah.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
__author__ = "Klaus-Uwe Mitterer"
|
||||
__maintainer__ = __author__
|
||||
__email__ = "info@klaus-uwe.me"
|
||||
__version__ = "0.1"
|
||||
|
||||
import requests, bs4, PIL.Image, io
|
||||
|
||||
def fileDownloader(url):
|
||||
filename = url.split('/')[-1]
|
||||
remote = requests.get(url, stream=True)
|
||||
with open(filename, 'wb') as outfile:
|
||||
for chunk in remote.iter_content(chunk_size=1024):
|
||||
if chunk:
|
||||
outfile.write(chunk)
|
||||
outfile.flush()
|
||||
|
||||
def siteHandler(p = 15):
|
||||
suppe = bs4.BeautifulSoup(requests.get('http://explosm.net/comics/' + str(p)).text)
|
||||
for img in suppe.find_all('img'):
|
||||
if "files.explosm.net/comics" in img.get('src'):
|
||||
fileDownloader("http:" + img.get('src'))
|
||||
for ne in suppe.find_all("a", class_="next-comic"):
|
||||
siteHandler(ne.get('href').split('/')[2])
|
||||
|
||||
if __name__ == "__main__":
|
||||
siteHandler()
|
||||
print("KTHXBAI")
|
||||
|
Loading…
Reference in a new issue