Created
August 4, 2023 09:46
-
-
Save jexp/09df199130a47493b5fbac0251b6159e to your computer and use it in GitHub Desktop.
Python script to download slideshares for a User
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
# docs https://www.slideshare.net/developers/documentation | |
# pip install xmltodict requests | |
import requests | |
import time | |
from hashlib import sha1 | |
import os | |
import json | |
import xmltodict | |
user = 'neo4j' | |
api_key = os.environ.get("SLIDESHARE_KEY") | |
api_secret = os.environ.get("SLIDESHARE_SECRET") | |
# compute current time seconds since epoch | |
ts = str(int(time.time())) | |
hash = sha1(bytes(api_secret + ts,"ascii")).hexdigest() | |
url = f"https://www.slideshare.net/api/2/get_slideshows_by_user?username_for={user}&api_key={api_key}&hash={hash}&ts={ts}" | |
# print(url) | |
r = requests.get(url) | |
print(r.status_code) | |
if r.status_code == 200: | |
dicts = xmltodict.parse(r.content) | |
print(len(dicts)) | |
f = open("slides.json","w") | |
f.write(json.dumps(dicts)) | |
f.close() | |
else: | |
print("Error: ", r.status_code, r.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment