Spaces:
Sleeping
Sleeping
debug
Browse files
app.py
CHANGED
@@ -172,13 +172,13 @@ def scrape(product_id, max_reviews=LIMIT):
|
|
172 |
has_next = True
|
173 |
|
174 |
logger.info("Extracting product reviews...")
|
175 |
-
while has_next and len(all_reviews) <= max_reviews:
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
|
183 |
reviews_df = pd.json_normalize(all_reviews)
|
184 |
reviews_df.rename(columns={"message": "comment"}, inplace=True)
|
|
|
172 |
has_next = True
|
173 |
|
174 |
logger.info("Extracting product reviews...")
|
175 |
+
# while has_next and len(all_reviews) <= max_reviews:
|
176 |
+
response = request_product_review(product_id, page=page)
|
177 |
+
data = response.json()["data"]["productrevGetProductReviewList"]
|
178 |
+
reviews = data["list"]
|
179 |
+
all_reviews.extend(reviews)
|
180 |
+
has_next = data["hasNext"]
|
181 |
+
page += 1
|
182 |
|
183 |
reviews_df = pd.json_normalize(all_reviews)
|
184 |
reviews_df.rename(columns={"message": "comment"}, inplace=True)
|