Skip to content

Instantly share code, notes, and snippets.

@Xnuvers007
Created May 19, 2024 09:35
Show Gist options
  • Save Xnuvers007/2f04b01cdcc29731a6e20bbc310a028a to your computer and use it in GitHub Desktop.
Save Xnuvers007/2f04b01cdcc29731a6e20bbc310a028a to your computer and use it in GitHub Desktop.
import requests
import os
url = input("Enter the SlideShare URL: ") # https://www.slideshare.net/StevanyStevany/materi-lengkap-tentang-power-point
filetype = input("Enter the filetype (pdf/pptx): ")
headers_get = {
'accept': '*/*',
'accept-language': 'id,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,sv;q=0.6',
'priority': 'u=1, i',
'referer': 'https://slidesaver.app/',
'sec-ch-ua': '"Chromium";v="124", "Microsoft Edge";v="124", "Not-A.Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0',
}
response_get = requests.get(
f'https://slidesaver.app/api/get-images?url={url}',
headers=headers_get,
)
images = response_get.json().get("images", [])
print("Retrieved images:", images)
headers_post = {
'accept': '*/*',
'accept-language': 'id,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,sv;q=0.6',
'content-type': 'application/json',
'origin': 'https://slidesaver.app',
'priority': 'u=1, i',
'referer': 'https://slidesaver.app/',
'sec-ch-ua': '"Chromium";v="124", "Microsoft Edge";v="124", "Not-A.Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0',
}
json_data = {
'images': images,
'type': filetype,
}
response_post = requests.post('https://slidesaver.app/api/get-slide', headers=headers_post, json=json_data)
response_content = response_post.content.decode('utf-8')
download_url = response_content.strip('"')
print(f"Download URL: {download_url}")
response_download = requests.get(download_url)
if response_download.status_code == 200:
get_title_from_url = download_url.split('/')[-1].split('.')[0]
filename = f'{get_title_from_url}.{filetype}'
# filename = 'output.pptx'
# # Check if the file exists and remove it
# if os.path.exists(filename):
# os.remove(filename)
# print(f"Removed existing file: {filename}")
# Save the new file
with open(filename, 'wb') as file:
file.write(response_download.content)
print(f'File downloaded and saved as {filename}')
else:
print(f'Failed to download the file. Status code: {response_download.status_code}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment