반응형
import time
from selenium import webdriver
from bs4 import BeautifulSoup
comments = open("C:/Users/eyeden-FF14/Desktop/comments.txt", 'w' , encoding='utf-8' )
browser = 'C:/Users/eyeden-FF14/Desktop/Python/Selenium/chrome/chromedriver.exe'
driver = webdriver.Chrome(browser)
driver.get('http://entertain.naver.com/comment/list?oid=109&aid=0003467821')
time.sleep(3)
for i in range(0, 10) :
driver.find_element_by_css_selector(".u_cbox_btn_more").click()
time.sleep(3)
i +=1
html = driver.page_source
bs = BeautifulSoup(html, 'html.parser')
contents = bs.find_all("span", {"class" : "u_cbox_contents"})
for i in contents :
comments.write(str(i) + '\n')
comments.close()
반응형
'Python' 카테고리의 다른 글
[워드클라우드] 파이썬 KoNLPy 패키지 설치 -1 (0) | 2017.01.24 |
---|---|
[네이버] 뉴스 댓글 크롤링 (0) | 2017.01.23 |
[파이썬3] find_element_by_css_selector 확인방법 (0) | 2017.01.23 |
[셀레니움] 테스트 (0) | 2017.01.23 |
[네이버] 추천검색어 크롤링3 (0) | 2017.01.18 |
댓글