Last active
February 6, 2020 22:08
-
-
Save wowkin2/2392ff45c4be2cad89ca963eb9c8852d to your computer and use it in GitHub Desktop.
Scripts for download photos from imageshack.com with original names
This file contains hidden or 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
/** | |
Following script will parse all photos on imageshack.com | |
and will prepare list of files with appropriate names (like it they were originally) | |
to be downloaded on the next step | |
Scroll till the end of the page, so all images will be lazy-loaded. | |
Press F12 in browser copy-paste following code and press Enter. | |
Copy result and add it to the following Python script. | |
**/ | |
var data = []; | |
$('.grid-photo').each(function(index, item){ | |
var img = $(item).find('img').attr('src'), | |
title = $(item).find('.title').html(); | |
data.push({'image': img, 'title': title}); | |
}); | |
JSON.stringify(data) | |
// copy following |
This file contains hidden or 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
""" | |
Script to download any High Resolution images imageshack.com by urls and store them to "images" folder. | |
Python version - 3 | |
""" | |
import urllib | |
data = [] | |
destination_path = 'images/' # ensure this path exists | |
downloaded_files = set() | |
for idx, record in enumerate(data): | |
print(idx, record) | |
try: | |
url_parts = record['image'].split('/') | |
del url_parts[4] # remove part of url that do resize | |
url = 'https:' + '/'.join(url_parts) | |
filename = record['title'] | |
if filename in downloaded_files: # To avoid issues when image name is shortened in browser | |
filename = filename + record['image'][-10:] | |
urllib.request.urlretrieve(url, destination_path + filename) | |
downloaded_files.add(filename) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment