반응형
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())
반응형
'🖥️ IT, 컴퓨터 > 🐍 Python' 카테고리의 다른 글
[Python] 초간단 지오코딩하기 (주소 만으로 경위도좌표 변환) :: Google Maps 지오코딩 API 활용 (0) | 2025.02.21 |
---|---|
[Python] 애플 앱스토어 리뷰 크롤링 라이브러리 :: app-store-scraper 0.3.5 (0) | 2025.02.17 |
[Python] 구글 지도 위에 마커 올리기 (gmplot과 Google Maps JavaScript API 이용) (0) | 2025.01.17 |
[IT] Python과 Google Map API를 이용해 경위도 좌표를 영문 주소로 변환 (0) | 2025.01.17 |
[Python] matplotlib으로 인구 피라미드 시각화하기 (0) | 2024.12.24 |
댓글