Untitled
unknown
plain_text
3 years ago
1.7 kB
8
Indexable
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(1)
search.send_keys(Keys.RETURN)
'''main = driver.find_element(By.ID, 'main')
print(main.text)'''
try:
main = WebDriverWait(driver, 10).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(1)
print(header.text)
except:
print('a')
driver.quit()
time.sleep(1000)
Editor is loading...