selenium - Gakgu/Gakgu.github.io GitHub Wiki
๊ฐ์
์น ํฌ๋กค๋ง์ ๊ฐ๋ฅํ๊ฒ ํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ. ์ฌ๋ฌ ์ธ์ด๋ก ๋ฐ์ธ๋ฉ๋์๋ค.
ํ์ด์ฌ
๋๋ถ๋ถ์ ์ฌ์ฉ๋ฒ์ Selenium with Python์ ์๊ฐ๋์ด ์๋ค.
๊ธฐ๋ณธ
chromedriver๋ฅผ ๋ค์ด๋ฐ์ ํ ๊ธฐ๋ณธ path์ ์์น์ํค๊ฑฐ๋ ์์น๋ฅผ ์์ค์์ ๋ช ์ํ๋ค.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://google.com")
driver.close()
ํฌ๋กฌ ์จ๊ธฐ๊ธฐ
option = webdriver.ChromeOptions()
option.add_argument("headless")
driver = webdriver.Chrome(chrome_options=option)
์์ ์ฐพ๊ธฐ
driver.find_element_by_id("id")
driver.find_elements_by_id("id")
driver.find_element_by_class_name("class name")
driver.find_elements_by_class_name("class name")
driver.find_element_by_xpath("//td[@class='title']")
driver.find_elements_by_xpath("//td[@class='title']")
๊ธ์ ์ฐ๊ธฐ
input_id = driver.find_element_by_id("id")
input_id.clear()
input_id.send_keys("[email protected]")
์ํฐ
from selenium.webdriver.common.keys import Keys
input_id.send_keys(Keys.ENTER)
ํด๋ฆญ
login_button= driver.find_element_by_class_name("login")
login_button.click()