프로그래밍/python
headless로 네이버 로그인 시도 중 pyperclip이 먹히지 않는 경우
이휘재123
2022. 12. 27. 17:35
반응형
def login(self):
driver = self.driver
try:
driver.get(f"https://nid.naver.com/nidlogin.login?url=https://section.cafe.naver.com/ca-fe")
time.sleep(1)
driver.execute_script(
f"document.querySelector('input[id=\"id\"]').setAttribute('value', '{self.naver_id}')"
)
time.sleep(1)
driver.execute_script(
f"document.querySelector('input[id=\"pw\"]').setAttribute('value', '{self.naver_pw}')"
)
time.sleep(1)
login_btn = driver.find_element(By.ID, "log.login")
login_btn.click()
time.sleep(1)
except Exception as e:
print(f"{self.naver_id} {self.naver_pw} 로그인에 실패했습니다.")
raise Exception(f"{self.naver_id} {self.naver_pw} 로그인에 실패했습니다. {str(e)}")
finally:
time.sleep(1)
자바스크립트로 아이디, 비밀번호에 value를 직접 입력했다.
반응형