-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50cc215
commit 6f851d9
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
import random | ||
import time | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
import selenium.webdriver.support.ui as ui | ||
from selenium.webdriver.support import expected_conditions as EC | ||
from selenium.common.exceptions import NoSuchElementException | ||
import pyderman | ||
|
||
driverpath = pyderman.install(browser=pyderman.chrome) | ||
driver = webdriver.Chrome(driverpath) | ||
|
||
driver.maximize_window() | ||
weburl = "https://www.youtube.com" | ||
driver.get(weburl) | ||
|
||
wait = ui.WebDriverWait(driver, 3000) | ||
|
||
while True: | ||
try: | ||
if EC.presence_of_element_located((By.XPATH,".//div/div/div/div/div/span/button/div[contains(text(),'Skip Ad')]")): | ||
button = driver.find_element(By.XPATH, ".//div/div/div/div/div/span/button/div[contains(text(),'Skip Ad')]") | ||
driver.execute_script("arguments[0].click();", button) | ||
print("ad skipped") | ||
time.sleep(2) | ||
else: | ||
continue | ||
|
||
except NoSuchElementException: | ||
print("no element detected") | ||
time.sleep(2) |
Binary file not shown.