작성
·
445
·
수정됨
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
0
반갑습니다. 스타트코딩입니다.
질문주신 페이지는 동적인 페이지입니다.
일반적인 requests + bs4로는 크롤링할 수 없고
셀레니움이나 네트워크 분석을 통한 크롤링 방법을 사용해야 합니다.
아래는 네트워크에서 원하는 정보가 있는 통신을 찾은 스샷입니다.
감사합니다. (_ _)