🖥️ IT, 컴퓨터/🐍 Python
[Python] 구글 플레이스토어 리뷰 크롤링 라이브러리 :: Google-Play-Scraper
김 홍시
2025. 2. 17. 15:42
반응형

https://pypi.org/project/google-play-scraper/
google-play-scraper
Google-Play-Scraper provides APIs to easily crawl the Google Play Store for Python without any external dependencies!
pypi.org
import time
import pandas as pd
from google_play_scraper import reviews, Sort
# 변수 설정
app_id = 'com.dena.automotive.taxibell' # 앱 패키지명 (정확히 확인 필요)
total_reviews = []
count_per_request = 10 # 요청당 리뷰 수 (너무 크면 차단 가능)
target_count = 50 # 목표 리뷰 수
request_interval = 3 # 요청 간 시간 간격 (초)
# 첫 요청
try:
result, continuation_token = reviews(
app_id,
lang='ko',
country='kr',
sort=Sort.NEWEST,
count=count_per_request,
)
total_reviews.extend(result)
time.sleep(request_interval)
# 반복 요청
while len(total_reviews) < target_count and continuation_token:
print(f"[INFO] 현재 리뷰 개수: {len(total_reviews)}")
try:
result, continuation_token = reviews(
app_id,
lang='ko',
country='kr',
sort=Sort.NEWEST,
count=count_per_request,
continuation_token=continuation_token,
)
if not result:
print("[WARN] 추가 리뷰를 가져올 수 없음. 루프 종료.")
break
total_reviews.extend(result)
time.sleep(request_interval)
except Exception as e:
print(f"[ERROR] 리뷰 요청 중 오류 발생: {e}")
break
except Exception as e:
print(f"[ERROR] 첫 요청 실패: {e}")
# 결과를 DataFrame으로 변환
if total_reviews:
playstore_reviews_df = pd.DataFrame(total_reviews[:target_count])
print(f"[INFO] 최종 리뷰 개수: {len(playstore_reviews_df)}")
else:
print("[ERROR] 리뷰를 가져오지 못했습니다.")
# 데이터 확인
print(playstore_reviews_df.head())

반응형