Guest User

download snapchat memories

a guest
Nov 26th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.46 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver import Keys
  3. from selenium.webdriver.common.by import By
  4. from selenium.webdriver.support.ui import WebDriverWait
  5. from selenium.webdriver.support import expected_conditions as ec
  6. from selenium.common.exceptions import TimeoutException
  7. import time
  8.  
  9. driver = webdriver.Firefox()
  10. driver.get('https://accounts.snapchat.com/accounts/v2/login')
  11. driver.maximize_window()
  12.  
  13. my_username = ""
  14. my_password = ""
  15.  
  16. wait = WebDriverWait(driver, 10)
  17.  
  18. # handle cookie pop up
  19. try:
  20.     cookie = wait.until(ec.visibility_of_element_located(
  21.         (By.XPATH, '/html/body/div[2]/div/div/div[4]/div/section/div/section/div[2]/div/div/div/div[3]/button[1]')))
  22.     cookie.click()
  23. except TimeoutException:
  24.     print("no cookie popup")
  25.  
  26. # login
  27. time.sleep(1)
  28. enter_username = driver.find_element(By.XPATH, '//*[@id="accountIdentifier"]')
  29. enter_username.send_keys(my_username, Keys.RETURN)
  30.  
  31. time.sleep(2)
  32. enter_password = driver.find_element(By.XPATH, '//*[@id="password"]')
  33. enter_password.send_keys(my_password, Keys.RETURN)
  34.  
  35. # navigate to "my data"
  36. my_data = wait.until(ec.visibility_of_element_located(
  37.     (By.XPATH, '/html/body/div/div[1]/main/div[3]/div[3]/div[1]/a[1]')))
  38. my_data.click()
  39.  
  40. # select download data
  41. select_data_xpath = {
  42.     'html': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[2]/section[1]/div[3]/div/div[3]/div/div/button',
  43.     'json': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[2]/section[1]/div[4]/div/div[3]/div/div/button',
  44.     'user': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[2]/section[1]/div[5]/div/div[3]/label',
  45.     'chat': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[6]/div/div[3]/label',
  46.     'spotlight': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[7]/div/div[3]/label',
  47.     'shopping': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[8]/div/div[3]/label',
  48.     'support': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[9]/div/div[3]/label',
  49.     'ranking': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[10]/div/div[3]/label',
  50.     'other': '/html/body/div[4]/div/main/div[2]/div/div[2]/div/div[3]/section[1]/div[12]/div/div[3]/label'
  51. }
  52.  
  53.  
  54. def click_data_buttons(dictionary):
  55.     for value in dictionary.values():
  56.         data_button = driver.find_element(By.XPATH, value)
  57.         data_button.click()
  58.  
  59.  
  60. click_data_buttons(select_data_xpath)
Advertisement
Add Comment
Please, Sign In to add comment