inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Python cơ bản và tạo nhiều ứng dụng tự động hóa khác nhau bằng cách sử dụng web crawling

Thực hành Scraping và Parsing không dùng Trình duyệt Web (2) - Tự động hóa Naver Cafe

네이버 로그인 질문이요

310

getup90828

5 câu hỏi đã được viết

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

python 웹-크롤링

Câu trả lời 2

1

niceman

안녕하세요.

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

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

감사합니다.

0

getup90828

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

현재 예제에서 error 발생

0

393

3

유튜브 동영상 다운로드

0

1486

2

Atom 에디터 관련

0

351

1

위시켓 폼데이터

0

284

1

스케줄러 사용 관련 질문 드립니다

0

643

1

selenium 에러

0

441

1

Progress bar 쓰레드 관련

0

499

1

Install Package 관련 문의

0

338

1

tkinter 샘플 코드 실행 오류 건

0

1280

1

4-7-6 네이버 & 카카오 주식 정보 가져오기

0

391

1

네이버자동로그인_by_selenium

0

883

1

위시캣 로그인 처리 및 크롤링 질문

0

355

1

2-8-1 네이버이미지 크롤링 질문

1

617

3

li:nth-of-type 질문

0

358

2

에러가 뜨는데 잘 모르겠어요ㅠ

0

406

2

Install Packages 항목이 안보이는 이유가 뭘까요?

0

411

2

환경변수 Path 설정 방법

0

643

1

웹 브라우저 없는 스크랩핑 및 파싱 실습(1) - 인프런

0

346

1

웹 브라우저 없는 스크랩핑 및 파싱 실습(1) -git주소

0

497

3

download2-8-1. py질문

0

213

1

ip 차단 당하는 거 같은데 아무리 랜덤주고, sleep 줘도 안 되는데 다른 방법 더 있을까요??

0

651

1

인프런 환경이 바뀌어서 제나름대로 하는데

0

199

1

다시올려주신 예제파일로하는데

0

195

1

아직도 에러가뜨나보네요?

0

591

1