네이버 게임 라운지 게시글 댓글 크롤링
557
프로그램초
작성한 질문수 3
0
크롤링 하다가 막혔는데 어떻게 해결할 수 있을까요??
URL : https://game.naver.com/lounge/Viking_Rise/board/detail/2583518
사용 코드
import requests
from bs4 import BeautifulSoup
import openpyxl
url = "https://game.naver.com/lounge/Viking_Rise/board/detail/2583518"
response = requests.get(url)
html = response.text
soup = BeautifulSoup(html, "html.parser")
comment_items = soup.select(".comment_item_text__1foPs")
workbook = openpyxl.Workbook()
sheet = workbook.active
sheet.title = "Crawled Comments"
sheet.cell(row=1, column=1, value="Comment Text")
sheet.cell(row=1, column=2, value="Attributes")
for index, comment_content in enumerate(comment_items, start=2):
comment_text = comment_content.get_text(strip=True)
comment_attributes = str(comment_content.attrs)
sheet.cell(row=index, column=1, value=comment_text)
sheet.cell(row=index, column=2, value=comment_attributes)
workbook.save("crawled_comments.xlsx")
print("Comment attributes have been crawled and saved to crawled_comments.xlsx")
답변 1
강의 수강 후 포트폴리오 준비 방향에 대해 조언 부탁드립니다.
2
50
1
Cursor 실행 문의
1
43
2
Spider와 Monster 구현 방식을 구분한 이유
1
24
1
프론트엔드 이력서 관련 질문
1
46
2






