Skip to content

Instantly share code, notes, and snippets.

@jexp
Created August 4, 2023 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jexp/09df199130a47493b5fbac0251b6159e to your computer and use it in GitHub Desktop.
Save jexp/09df199130a47493b5fbac0251b6159e to your computer and use it in GitHub Desktop.
Python script to download slideshares for a User
# 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