Created
May 9, 2023 09:21
-
-
Save kevinski303/0eb2064c9c9aad9e993d270545f54325 to your computer and use it in GitHub Desktop.
This file contains 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
from selenium import webdriver | |
from selenium.webdriver.firefox.service import Service | |
from selenium.webdriver.firefox.options import Options | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.wait import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from webdriver_manager.firefox import GeckoDriverManager | |
import time | |
import random | |
counter = 0 | |
while counter <= 10: | |
options = Options() | |
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=options) | |
driver.get("https://soundcloud.com/kevqube/tnc-115") | |
try: | |
element = WebDriverWait(driver, 10).until( | |
EC.presence_of_all_elements_located((By.ID, "onetrust-accept-btn-handler")) | |
) | |
finally: | |
accept = driver.find_element("xpath", '//*[@id="onetrust-accept-btn-handler"]').click() | |
links = driver.find_elements("xpath", "/html/body/div[1]/div[2]/div[2]/div/div[2]/div/div[2]/div[2]/div/div/div[1]/a") | |
sleeptime = random.randint(1,10) | |
print("playing for ", sleeptime ) | |
time.sleep(sleeptime) | |
driver.close() | |
sleeptime = random.randint(1,10) | |
print("sleeping for ", sleeptime) | |
time.sleep(sleeptime) | |
counter = counter + 1 | |
print("count is:", counter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment