Created
December 30, 2020 13:23
-
-
Save renbaoshuo/70d5715b253d67e802f46945dec211ff to your computer and use it in GitHub Desktop.
Download all uploaded SMMS images.
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 | |
import os | |
import json | |
import pathlib | |
import sys | |
proxy = "http://127.0.0.1:7890" | |
print("\nusing proxy: " + proxy + "\n\n====================\n") | |
proxies = {"http": proxy, "https": proxy} | |
def getUploadedImages(token): | |
url = "https://sm.ms/api/v2/upload_history" | |
headers = {"Authorization": token} | |
return requests.get(url, headers=headers, proxies=proxies).text | |
data = json.loads(getUploadedImages(sys.argv[1])) | |
print("Total: " + str(len(data["data"])) + "\n") | |
for img in data["data"]: | |
path = "./data/" + img["storename"] | |
if not pathlib.Path(path).is_file(): | |
pic = requests.get(img["url"], proxies=proxies).content | |
f = open(path, "wb") | |
f.write(pic) | |
f.close() | |
del pic | |
print("Successfully get "+img["storename"]+" .") | |
else: | |
print(""+img["storename"]+" is already exists.") | |
print("\nDone!\n====================\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment