멀티프로세싱 + 구글 스크래퍼 실습을 진행하였다
딕셔너리 value 추출방법
- 딕셔너리[‘key값’]
- 딕셔너리.get(‘키값’)
- 모든 value : 딕셔너리.values()
- 모든 key값 : 딕셔너리.keys()
구글 스크래퍼 사용법
from google_play_scraper import app
from google_play_scraper import reviews
from google_play_scraper import Sort
앱정보 추출
result=app(
'앱의 패키지 이름', # 예 ) com.nianticlabs.pokemongo
lang='ko',
country='kr'
)
앱의 리뷰 정보 추출
review_results, continuation_token = reviews(
'앱의 패키지명',
lang='ko', # defaults to 'en'
country='kr', # defaults to 'us'
sort=Sort.MOST_RELEVANT, # defaults to Sort.NEWEST
count=3, # defaults to 100
)
# If you pass `continuation_token` as an argument to the reviews function at this point,
# it will crawl the items after 3 review items.
review_results, _ = reviews(
'앱의 패키지명',
continuation_token=continuation_token # defaults to None(load from the beginning)
)
continuation_token은 다음 것을 뽑을 수 있게 해주는 것같다.
리스트 안에 있는 딕션너리 값 추출 categories=list(m['name'] for m in result['categories'])
escape()는 패턴을 입력 받으면 특수문자들에 이스케이프(백슬래쉬) 처리를 한 다음 반환합니다.
- run 옵션
- 실행할때 옵션을 준다 예) main.py -옵션
- import sys
- sys.argv #['main.py', '-info'] sys.argv[1]로 옵션 설정
- 실행할때 옵션을 준다 예) main.py -옵션
반응형
'python' 카테고리의 다른 글
02/13~02/15 정리 (0) | 2024.02.15 |
---|---|
8일차 (1) | 2024.02.09 |
6일차 (1) | 2024.02.07 |
5일차 교육 (0) | 2024.02.06 |
교육 4일차 paramiko+requests+정규식 (1) | 2024.02.03 |