lljz66 commited on
Commit
40dbeaa
·
verified ·
1 Parent(s): da28b5a

Upload google_play_scraper/features/reviews.py

Browse files
google_play_scraper/features/reviews.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Extract application reviews."""
2
+ from typing import List, Dict
3
+ from google_play_scraper.utils.http_utils import get
4
+ from google_play_scraper.constants.google_play import REVIEWS_URL_FORMAT
5
+ from google_play_scraper.constants.element import REVIEWS_SELECTORS
6
+
7
+
8
+ def reviews(app_id: str, lang: str = "en", country: str = "us", sort: str = "newest", n_pages: int = 1) -> List[Dict]:
9
+ """Get app reviews."""
10
+ url = REVIEWS_URL_FORMAT.format(app_id=app_id, lang=lang, country=country, sort=sort)
11
+ response = get(url)
12
+
13
+ reviews_list = []
14
+ for item in response.get("data", []):
15
+ review_data = {}
16
+ for key, selector in REVIEWS_SELECTORS.items():
17
+ review_data[key] = item.get(selector)
18
+ reviews_list.append(review_data)
19
+
20
+ return reviews_list