+ # People like images
+ image_dir = os.path.join(self.download_dir, 'images')
+ try:
+ os.mkdir(image_dir)
+ for imagelink in soup.find_all('span', {'class':'gallery-slider'})[0] \
+ .find_all('div', {'class':'gallery-photo'}):
+ url = imagelink['data-full']
+ filename = os.path.basename(url)
+ if filename.endswith('stl'):
+ filename = "{}.png".format(filename)
+ image_req = requests.get(url)
+ with open(os.path.join(image_dir, filename), 'wb') as handle:
+ handle.write(image_req.content)
+ except Exception as exception:
+ print("Failed to download {} - {}".format(filename, exception))
+ os.rename(self.download_dir, "{}_failed".format(self.download_dir))
+ return
+
+
+
+