Last active
January 26, 2024 06:01
-
-
Save secemp9/de790ba243577f51e9029af5774001ed to your computer and use it in GitHub Desktop.
Get video links from Loom's folder link (no commandline support)
This file contains hidden or 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
| import sys | |
| import platform | |
| import time | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from selenium.webdriver.support import expected_conditions as EC | |
| import undetected_chromedriver as uc | |
| from selenium.webdriver.common.keys import Keys | |
| import pyperclip | |
| from bs4 import BeautifulSoup | |
| # Hardcoded credentials | |
| loom_email = "your_email_here" | |
| loom_password = "your_password_here" | |
| url_to_visit = "url_you_want_to_visit" | |
| def main(): | |
| driver = uc.Chrome() | |
| driver.get("https://www.loom.com/login") | |
| WebDriverWait(driver, 300).until( | |
| EC.presence_of_element_located((By.ID, "email")) | |
| ) | |
| email = driver.find_element(By.ID, "email") | |
| email.clear() | |
| email.send_keys(loom_email) | |
| WebDriverWait(driver, 300).until( | |
| EC.presence_of_element_located((By.ID, "email-signup-button")) | |
| ) | |
| time.sleep(1) | |
| login_button = driver.find_element(By.ID, "email-signup-button") | |
| # Try clicking until it succeeds | |
| max_attempts = 1000 | |
| for attempt in range(max_attempts): | |
| try: | |
| login_button.click() | |
| break | |
| except Exception as e: | |
| print(f"Click attempt {attempt + 1} failed: {e}") | |
| time.sleep(0.01) # Wait for 2 seconds before retrying | |
| if attempt == max_attempts - 1: | |
| raise | |
| original_window = driver.current_window_handle | |
| all_windows = driver.window_handles | |
| new_window = [window for window in all_windows if window != original_window][0] | |
| driver.switch_to.window(new_window) | |
| WebDriverWait(driver, 300).until( | |
| EC.element_to_be_clickable((By.ID, "identifierId")) | |
| ).send_keys(loom_email) | |
| driver.find_element(By.ID, "identifierNext").click() | |
| pyperclip.copy(loom_password) | |
| WebDriverWait(driver, 300).until( | |
| EC.element_to_be_clickable((By.NAME, "Passwd")) | |
| ).click() | |
| password_field = driver.find_element(By.NAME, "Passwd") | |
| if platform.system() == 'Darwin': # MacOS | |
| password_field.send_keys(Keys.COMMAND, 'v') | |
| else: # Windows and others | |
| password_field.send_keys(Keys.CONTROL, 'v') | |
| driver.find_element(By.ID, "passwordNext").click() | |
| time.sleep(5) | |
| driver.switch_to.window(original_window) | |
| driver.get(url_to_visit) | |
| time.sleep(5) | |
| page_source = driver.page_source | |
| soup = BeautifulSoup(page_source, 'html.parser') | |
| links = soup.find_all('a', class_='video-card_videoCardLink_37D') | |
| for link in links: | |
| video_url = link.get('href') | |
| video_title = link.find('h2').text # Extracting the text from the h2 tag | |
| print(f"Title: {video_title}, URL: {video_url}") | |
| driver.close() | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment