[app_store_scraper] [ERROR] Base - Something went wrong: 'latin-1' codec can't encode characters in position 30-32: ordinal not in range(256)

2024. 4. 18. 00:01Trouble shooting

[app_store_scraper] [ERROR] Base - Something went wrong: 'latin-1' codec can't encode characters in position 30-32: ordinal not in range(256)

 

 

2024-04-17 19:17:25,749 [INFO] Base - Initialised: AppStore('kr', '{앱이름-앱이름}', {앱id숫자})  # {앱이름-앱이름} 형태의 입력, {앱id 숫자}는 int 
2024-04-17 19:17:25,750 [INFO] Base - Ready to fetch reviews from: https://apps.apple.com/kr/app/{앱이름-앱이름}/id{앱id숫자}
2024-04-17 19:17:25,785 [ERROR] Base - Something went wrong: 'latin-1' codec can't encode characters in position 30-32: ordinal not in range(256)
2024-04-17 19:17:25,785 [INFO] Base - [id:{앱id숫자}] Fetched 0 reviews (0 fetched in total)

 

from app_store_scraper import AppStore
import pandas as pd
import json

app = AppStore(country="kr", app_name="{한한한-글글글}", app_id={int})
			 # {한한한-글글글} 형태의 한글 str, {int} appstore 에 나오는 app_id 값

# 리뷰 수집 시작
app.review(how_many=100)

# 리뷰 데이터를 JSON으로 저장
with open('reviews.json', 'w', encoding='utf-8') as f:
    json.dump(app.reviews, f, ensure_ascii=False, indent=4)

 

상황

이런식의 코드로 app_store_scraper 를 이용하여 Appstore 에 접근해 리뷰를 크롤링하는 게 목표입니다.

로그의 2번째 줄을 보면 분명 접근 까지 잘되는데,

fetch를 시도하면 바로 'latin-1' 인코딩 오류를 띄웁니다.

 

 

해결

 

먼저 해결방법부터 얘기드리자면

apps = {'xxxyyy': {int}}

중간의 ' - ' 를 제거하고, 영어로 바꿨습니다.

1. 아마 "한한한 글글글" 이런 어플인데 주소창에서 표시하기위해 공백을 ' - ' 로 채웠던 것 같습니다.

2. 한글 -> 영어로 바꿈.

 

나중에 확인하여 정확히 1 ' - ' 문제인지 2 '한글' 때문이였는지 수정하겠습니다.

 

 

실패했던 방법들 입니다.

 

1. 환경변수에서 시스템 기본 인코딩 설정.

set PYTHONIOENCODING=utf8

 

2. 코드내 인코딩 설정

utf-8 로 인수를 주었으나 역시 실패.

 

3. app_store_scraper는 requests 라이브러리를 사용합니다.

http 요청을 보낼때 Accept-Charset 헤더를 UTF-8 로 명시하기.

실패.

 

 

아마도 '-' 나 '한글' 때문이였을것 같습니다.

(추후수정)

 

728x90