Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
2
Indexable
Never
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from contextlib import contextmanager

from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
import time, os
import funkcje

chrome_options = Options()

chrome_options.add_experimental_option("detach", True)
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
#Chrome Options (Extra Things For The Driver To Do On Start)
#Start With Window Maximized (Simple Detection Avoidance)
chrome_options.add_argument("start-maximized")
#Start With No Useless Popups (Simple Detection Avoidance)
chrome_options.add_argument("disable-infobars")


driver.get("https://www.techwithtim.net")
search = driver.find_element(By.NAME, 's')
search.send_keys("test")
time.sleep(3)
search.send_keys(Keys.RETURN)

'''main = driver.find_element(By.ID, 'main')
print(main.text)'''

try:
    WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "main")))
    main = driver.find_element(By.ID, "main")
    time.sleep(3)
    print(main.text)
except:
    print('a')
    driver.quit()



time.sleep(5)