Last active
January 26, 2024 05:33
-
-
Save secemp9/dfee57fa3fcdd4f6d58813554dac9784 to your computer and use it in GitHub Desktop.
Loom get video links from folder (version that work with commandline)
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 | |
| def main(loom_email, loom_password, url_to_visit): | |
| 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")) | |
| ) | |
| login_button = driver.find_element(By.ID, "email-signup-button") | |
| login_button.click() | |
| 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__": | |
| if len(sys.argv) != 4: | |
| print("Usage: python script.py <email> <password> <url>") | |
| else: | |
| main(sys.argv[1], sys.argv[2], sys.argv[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment