본문 바로가기
개발일기/파이썬

셀레늄 네이버 로그인

by 프로그래머콩 2019. 4. 23.

# selenium_test.py

from selenium import webdriver
import os
import sys

# Create your views here.

# determine if application is a script file or frozen exe
if getattr(sys, 'frozen', False):
application_path = os.path.dirname(sys.executable)
elif __file__:
application_path = os.path.dirname(__file__)
path_dir = '/chromedriver/chromedriver'

config_path = application_path+path_dir
print(config_path)
driver = webdriver.Chrome(config_path)

delay = 3
driver.implicitly_wait(delay)

driver.get('https://nid.naver.com/nidlogin.login?mode=form&url=http://zezrztzy93.blog.me')
# 아이디/비밀번호를 입력해준다.

id = '아이디'
pw = '패스워드'

driver.execute_script("document.getElementsByName('id')[0].value=\'" + id + "\'")
driver.execute_script("document.getElementsByName('pw')[0].value=\'" + pw + "\'")
# 로그인 버튼을 눌러주자.
driver.find_element_by_xpath('//*[@id="frmNIDLogin"]/fieldset/input').click()

 

 

 

출처 - https://sab-jil.tistory.com/2