-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
NcafeWriteAtt 가 정의되지 않았다는 에러
20.06.06 16:10 작성 조회수 142
0
Traceback (most recent call last): File "/Users/usang-in/끼리끼리 Dropbox/우상인/study/section3/3-7-1.py", line 11, in <module> class NcafeWriteAtt: File "/Users/usang-in/끼리끼리 Dropbox/우상인/study/section3/3-7-1.py", line 48, in NcafeWriteAtt a = NcafeWriteAtt() NameError: name 'NcafeWriteAtt' is not defined
[Finished in 0.141s]
안녕하세요. 질문이 있는데
혹시 저 에러가 뜨는 이유가 무엇인지 궁금합니다.
import sys
import io
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
class NcafeWriteAtt:
#클래스 초기화 실행 (webdriver 설정)
def __init__(self):
chrome_options = Options()
chrome_options.add_argument("--headless") #CLS 서버
self.driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="/Users/usang-in/끼리끼리 Dropbox/우상인/study/section3/webdriver/chrome/chromedriver")
self.driver.implicitly_wait(5)
#네이버 카페 로그인 && 출석 체크
def writeAttendCheck(self):
self.driver.get("https://nid.naver.com/nidlogin.login")
self.driver.find_element_by_name('id').send_keys('tntnvhs')
self.driver.find_element_by_name('pw').send_keys('wkdtnwl1534!')
self.driver.find_element_by_xpath('//*[@id="log.login"]').click()
self.driver.implicitly_wait(30)
self.driver.get('https://cafe.naver.com/MemoList.nhn?search.clubid=18764756&search.menuid=5&viewType=pc')
self.driver.implicitly_wait(30)
self.driver.switch_to_frame('cafe_main')
self.driver.find_element_by_id('contents').send_keys('반가워요~')
self.driver.find_by_xpath('//*[@id="main-area"]/div[3]/div[1]/form/fieldset/div/button').click()
time.sleep(3)
# 소멸자
def __del__(self):
#self.driver.close() 현재 실행 포커스된 영역을 종료
self.driver.quit() #selenium 전체 프로그램 종료
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
소스코드 보면 위에서 분명 NcafeWriteAtt 가 정의되었는데 왜 그럴까요..
답변을 작성해보세요.
0
좋은사람
지식공유자2020.06.07
안녕하세요.
NcafeWriteAtt 관련해서 소스코드에서 문제는 안보이는데요.
혹시 들여쓰기나 다른 부분을 살펴보시고 클래스 선언을
class NcafeWriteAtt();
class NcafeWriteAtt(object):
등으로 변경해서 실행해보세요!
답변 1