Created
December 16, 2015 15:19
-
-
Save anonymous/3ea186a7b76eee7f8a73 to your computer and use it in GitHub Desktop.
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
try: | |
#Wir brauchen aktuelle Versionen von BeautifulSoup und Requests | |
from bs4 import BeautifulSoup; | |
import requests | |
import shutil | |
# Scrapen wir mal los | |
n = 24 #Hier wirfst du die Anzahl der Seiten rein, die eine Kategorie hat (siehst du in der Pagination) | |
#(Mir ist voll und ganz bewusst, dass man dass auch einfach aus der Seite scrapen könnte, aber das | |
#war zeitlich recht sinnlos) | |
i = 1 #Hier änderst du nüx | |
io = 0 #Hier auch nicht | |
while i <= n: | |
print("now on page" + str(i)) | |
page = requests.get("http://www.posemaniacs.com/category/pose/page/" + str(i)).text #HIER wirfst du die URL der Kategorie rein (siehe Sidebar) | |
soup = BeautifulSoup(page, "html.parser") | |
entries = soup.find_all("img", attrs={"height" : "118"}) #Ja, wir erkännen die richtigen Bilder anhand ihrer Höhe | |
for e in entries: | |
link = "http://www.posemaniacs.com" + e["src"].replace("_thumb", "") | |
print("Link: " + link) | |
path = "./dest/pose" + str(io) + ".jpg" | |
r = requests.get(link, stream=True) | |
if r.status_code == 200: | |
with open(path, 'wb') as f: | |
r.raw.decode_content = True | |
shutil.copyfileobj(r.raw, f) | |
io = io +1 | |
i = i + 1 | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment