๐จ๐ผ๐ป๊ฐ๋ฐ/์
๋ ๋์
์ ๋ ๋์ - ๋ค์ด๋ฒ ๋ก๊ทธ์ธ ๋ด ํ์ง ์ฐํํ๊ธฐ
Janger
2022. 2. 8. 08:15
728x90
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pyperclip
import time
uid = '{์์ด๋}'
upw = '{๋น๋ฐ๋ฒํธ}'
driver = webdriver.Chrome('chromedriver.exe')
driver.implicitly_wait(15)
driver.get('https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com')
pyperclip.copy(uid)
time.sleep(1)
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/form/ul/li/div/div[1]/div[1]/input').send_keys(Keys.CONTROL + 'v')
pyperclip.copy(upw)
time.sleep(1)
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[1]/form/ul/li/div/div[1]/div[2]/input').send_keys(Keys.CONTROL + 'v')
driver.find_element_by_xpath('//*[@id="log.login"]').click()
๋ฐ๋ก ์์ด๋/๋น๋ฐ๋ฒํธ๋ฅผ send_key()๋ก ๋ณด๋ด์ฃผ๋ ๊ฒ์ด ์๋, ํด๋ฆฝ๋ณด๋๋ฅผ ์ด์ฉํด ๋ณต์ฌ ๋ถ์ฌ๋ฃ๊ธฐ๋ก ๊ฐ์ ๋ฃ๊ณ ์ ์ถํด์ฃผ๋ฉด ๋ด์ ๊ฐ์ง ๋ชปํ๋ค.
์ฐธ์กฐ:
์ ๋ ๋์ ์น ํฌ๋กค๋ง ๋ด ํ์ง ์ฐํ 2ํ ๋ค์ด๋ฒ ๋ก๊ทธ์ธ ์บก์ฐจ ํผํ๊ธฐ - ๋ปฅ๋ซ๋ฆฌ๋ ํ์ด์ฌ ์ฝ๋ ๋ชจ์
๋ค์ด๋ฒ์์ ๋ก๊ทธ์ธ์ ์๋ํ๋ฉด ๋ก๋ด์์ ํ์งํ๋ ์บก์ฐจ(captcha) ๊ฐ ๋ฌ๋ค. ๊ฒฐ๋ก ๋ถํฐ ๋งํ์๋ฉด ์ด๋ฅผ ๋จ์ง ์๊ฒํ๊ณ ๋ค์ด๋ฒ์ ์จ์ ํ ๋ก๊ทธ์ธํ๋ ๋ฐฉ๋ฒ์ ์๊ฐํ๋ค.
pythondocs.net
728x90