반응형
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를 직접 입력했다.
반응형
'프로그래밍 > python' 카테고리의 다른 글
dictionary list의 값 바꾸기 (0) | 2022.12.29 |
---|---|
[selenium] tor 브라우저를 사용한 ip 우회 (0) | 2022.12.28 |
python dict 배열의 중복 제거 (0) | 2022.12.26 |
[pyqt5] QTableWidget 아이템 추가 (0) | 2022.12.23 |
javascript만을 이용해서 xpath 요소를 클릭하는 코드 (0) | 2022.12.19 |