Skip to content

Instantly share code, notes, and snippets.

@Shivanshu-Gupta
Created December 12, 2021 08:26
Show Gist options
  • Save Shivanshu-Gupta/283f58f9f4dfdfe095e2e93ac430bec3 to your computer and use it in GitHub Desktop.
Save Shivanshu-Gupta/283f58f9f4dfdfe095e2e93ac430bec3 to your computer and use it in GitHub Desktop.
slideslive-downloader
import os
import requests
# import selenium.webdriver as webdriver
import seleniumwire.webdriver as webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
URL = 'https://slideslive.com/embed/presentation/38969236?embed_parent_url=https%3A%2F%2Fnips.cc%2Fvirtual%2F2021%2Ftutorial%2F21891&embed_container_origin=https%3A%2F%2Fnips.cc'
DOWNLOADS_DIR = '/Users/shivanshu/Downloads/neurips/tut-structural-priors/'
driver = webdriver.Firefox()
driver.get(URL)
# driver.implicitly_wait(10)
element = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.CLASS_NAME, 'slp__bigButton--next')))
b = driver.find_element(By.CLASS_NAME, 'slp__bigButton--next')
# not working
if False:
def get_image_url():
return driver.find_element(By.CSS_SELECTOR, '.slp__slidesPlayer__content > img').get_attribute('src').split('?')[0]
images_urls = [get_image_url()]
for i in range(113):
b.click()
images_urls.append(get_image_url())
if True:
for i in range(113): b.click()
images_urls = list([r.url.split('?')[0] for r in driver.requests if r.method == 'GET' and 'slides/' in r.url])
# For every line in the file
for i, url in enumerate(images_urls):
# Split on the rightmost / and take everything on the right side of that
# name = url.rsplit('/', 1)[-1]
name = f'{i:03}.png'
r = requests.get(url.replace('small', 'big').replace('medium', 'big'))
# Combine the name and the downloads directory to get the local filename
filename = os.path.join(DOWNLOADS_DIR, name)
with open(filename, 'wb') as outfile:
outfile.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment