Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.5 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 selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
import time, os
chrome_options = Options()
webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
#Chrome Options (Extra Things For The Driver To Do On Start)
options = webdriver.ChromeOptions()

#Start With Window Maximized (Simple Detection Avoidance)
options.add_argument("start-maximized")

#Start With No Useless Popups (Simple Detection Avoidance)
options.add_argument("disable-infobars")

#Find The Main Directory That This Script Is In 
MAIN_DIR = os.path.dirname(os.path.abspath(__file__))

#Add This Directory To /chromedriver.exe To Try To Find The Driver
WebDriverPath = MAIN_DIR + '/chromedriver.exe'

#Define Our Driver And Pass In Our Options And Location Of Chromedriver
driver = webdriver.Chrome(options=options, executable_path=WebDriverPath)

driver.get("https://www.techwithtim.net")
search = driver.find_element_by_name("s")
search.send_keys("test")
time.sleep(5)
search.send_keys(Keys.RETURN)

time.sleep(5)

print(driver.page_source)

driver.quit()