728x90
반응형
네이버 기사의 댓글에서 next버튼을 클릭하는 소스의 일부이다.
webpage = webdriver.Chrome(self.chrome_path)
webpage.get(response.url)
#넥스트 버튼을 찾아온다.
next_button = self.find_child_page_next_button(commentID, webpage)
#넥스트 버튼이없으면 반복문 종료
if not next_button: break
#있으면 버튼 클릭
next_button.click()
#버튼 클릭
def find_child_page_next_button(self, parentID, webpage):
try:
child_next_button = webpage.find_element_by_xpath(
'//li[contains(@data-info,"'+ parentID +'")]//a[@class="u_cbox_next"]')
except NoSuchElementException:
return None
return child_next_button
728x90
반응형
'개발관련' 카테고리의 다른 글
파이썬 강좌3 - 파이썬 제어문 (1) | 2024.12.20 |
---|---|
파이썬 강좌 2 - 파이썬 기본 문법 (0) | 2024.12.20 |
파이썬 강좌 1 - 파이썬이란, 파이썬 설치 (1) | 2024.12.20 |
파이썬 웹크롤링 문제 (1) | 2024.12.20 |
파이썬을 이용한 웹크롤링! (0) | 2024.12.20 |
매일 같은 시간에 특정 스크립트가 실행되게 하는 코드 (1) | 2024.12.20 |
파이썬 백그라운드로 실행하기 (0) | 2024.12.20 |
파이썬 서버와 데이터 주고받을때 주의 사항 (0) | 2024.12.20 |