• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 분석

  • 해결 여부

    미해결

네이버 로그인 질문이요

20.04.14 03:24 작성 조회수 141

0

인터넷으로 찾아보니까 클립보드를 이용하는 방법이 있어서 해보았습니다. 네이버에서 로그인 까지는 성공하는데

    self.driver.get('https://cafe.naver.com/AttendanceView.nhn?search.clubid=18824112&search.menuid=98')

여기서 부터는 실행이 안되버리네요 이유를 모르겠네요

import sys

import io

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.chrome.options import Options

import time

import pyperclip

 

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')

sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

 

#chrome_options = Options()

#chrome_options.add_argument("--headless") #CLI

 

class NcafeWriteAtt:

    #초기화 실행(webdriver 설정)

    def __init__(self):

        #chrome_options = Options()

        #chrome_options.add_argument("--headless") #CLI

        #self.driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="C:/pythonworkspaace/test_src/section3/webdriver/chrome/chromedriver")

        self.driver = webdriver.Chrome('C:/pythonworkspaace/test_src/section3/webdriver/chrome/chromedriver')

        self.driver.set_window_size(1920, 1280)

        self.driver.implicitly_wait(5)

 

    #네이버 카페 로그인 && 출석 체크

    def writeAttendCheck(self):

        self.driver.get('https://www.naver.com')

        login_btn = self.driver.find_element_by_class_name('ico_local_login')

        login_btn.click()

        time.sleep(1)

 

        tag_id = self.driver.find_element_by_name('id')

        tag_pw = self.driver.find_element_by_name('pw')

        tag_id.clear()

        time.sleep(1)

 

        tag_id.click()

        pyperclip.copy('아이디')

        tag_id.send_keys(Keys.CONTROL, 'v')

        time.sleep(1)

 

        tag_pw.click()

        pyperclip.copy('비밀번호')

        tag_pw.send_keys(Keys.CONTROL, 'v')

        time.sleep(1)

 

        login_btn = self.driver.find_element_by_id('log.login')

        login_btn.click()

 

        #self.driver.implicitly_wait(1)

        self.driver.get('https://cafe.naver.com/AttendanceView.nhn?search.clubid=18824112&search.menuid=98')

        self.driver.implicitly_wait(30)

        self.driver.switch_to_frame('cafe_main')

        self.driver.find_element_by_id('cmtinput').send_keys('반갑습니다!!.')

        self.driver.find_element_by_xpath('//*[@id="btn-submit-attendance"]').click()

        time.sleep(10)

 

        #소멸자

        def __del__(self):

            #self.driver.close() #현재 실행 포커스 된 영역을 종료

            self.driver.quit() #Seleninum 전체 프로그램 종료

            print("Removed driver Object")

 

#실행

if __name__ == '__main__':

    #객체 생성

    a = NcafeWriteAtt()

    #시작

    start_time = time.time()

    #프로그램 실행

    a.writeAttendCheck()

    #종료시간 출력

    print("--Total %s seconds --" % (time.time() - start_time))

    #객체 소멸

    del a

답변 2

·

답변을 작성해보세요.

1

안녕하세요.

현재 selenium 로그나 기타 메세지 없이 디버깅을 하는것은 쉽지 않네요 ㅠ

후에 소스코드 실행해보고 예제를 수정해서 올려드리겠습니다.

감사합니다.

0

애디님의 프로필

애디

질문자

2020.04.16

저 소스 중  id / pw 붙여넣기 > 로그인 버튼 클릭. 이 다음에 sleep 이랑 강사님이 말씀하신 명시적인 wait 10 정도 주니까 정상 으로 출석 게시판에 글을 쓰는걸 확인 했습니다.