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()

options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
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)
options.add_argument("start-maximized")
#Start With No Useless Popups (Simple Detection Avoidance)
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)
try:
    main = WebDriverWait(driver, 50).until(EC.presence_of_element_located((By.ID, 'main'))
)
    articles = main.find_elements((By.TAG_NAME,'article'))
    for article in articles:
       header = article.find_element((By.CLASS_NAME,'entry-summary'))
       time.sleep(3)
       print(header.text)

except:
    driver.quit()


try:
  print(x)
except:
  print("gdsdf")