driver = webdriver.Chrome()
driver.get("https://www.ted.com/talks")
driver.find_element(By.CSS_SELECTOR, "#banner-secondary").text
contents = driver.find_elements(By.CSS_SELECTOR, "#browse-results > .row > .col")
print(len(contents))
contents[0].find_element(By.CSS_SELECTOR, '.media__message .ga-link').text
titles = []
for content in contents:
title = content.find_element(By.CSS_SELECTOR, '.media__message .ga-link').text
titles.append(title)
print(titles[:3], len(titles))
이벤트 발생 기능(값 입력, 클릭 이벤트등)은 화면에 해당 엘리먼트가 보여야 합니다.
한국어 선택
driver.find_element(By.CSS_SELECTOR, '#languages [lang="ko"]').click()
contents = driver.find_elements(By.CSS_SELECTOR, "#browse-results > .row > .col")
titles = []
for content in contents:
title = content.find_element(By.CSS_SELECTOR, '.media__message .ga-link').text
titles.append(title)
print(titles[-3:])
links = []
for content in contents:
link = content.find_element(By.CSS_SELECTOR, '.media__message .ga-link').get_attribute("href")
links.append(link)
print(links[-3:])
driver.quit()
driver = webdriver.Chrome()
version = driver.capabilities["browserVersion"]
print(version)
driver.quit()
options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(options=options)
driver.get("https://www.ted.com/talks")
text = driver.find_element(By.CSS_SELECTOR, "#banner-secondary").text
driver.quit()
print(text)