Python API for Google play store scraping



我想从谷歌Play商店中抓取应用程序的评论。我想使用Python API来抓取评论。我知道有像硒和美丽汤这样的API,您可以在其中提供网络链接来抓取数据。我对使用像 StackAPI 这样的 API(用于抓取堆栈溢出(更感兴趣,您不需要提供任何网络链接。当我在互联网上搜索时,我发现没有全面的 API 可用于从 Play 商店中抓取评论。例如,Python 中的play_scraper API 提供了有关 API 的详细信息,但不会抓取与应用程序相关的评论。有没有人指导我应该使用哪一个来抓取谷歌 Play 商店?

如果您还没有找到那个,这里是 python 包的链接,可以从 google Play 商店抓取评论。

https://pypi.org/project/google-play-scraper/

我试了一下,它的工作非常好。

你可以看看SerpApi。我们为您处理代理、解决验证码并解析所有丰富的结构化数据。

使用此 API,您每页最多可以检索 199 条评论,然后使用next_page_token获取其余评论。

用于检索YouTube评论的python代码示例(也可以在其他库中使用(:

from serpapi import GoogleSearch
params = {
"api_key": "SECRET_API_KEY",
"engine": "google_play_product",
"store": "apps",
"gl": "us",
"product_id": "com.google.android.youtube",
"all_reviews": "true"
}
search = GoogleSearch(params)
results = search.get_dict()

示例 JSON 输出:

"reviews": [
{
"title": "Qwerty Jones",
"avatar": "https://play-lh.googleusercontent.com/a/AATXAJwSQC_a0OIQqkAkzuw8nAxt4vrVBgvkmwoSiEZ3=mo",
"rating": 3,
"snippet": "Overall a great app. Lots of videos to see, look at shorts, learn hacks, etc. However, every time I want to go on the app, it says I need to update the game and that it's "not the current version". I've done it about 3 times now, and it's starting to get ridiculous. It could just be my device, but try to update me if you have any clue how to fix this. Thanks :)",
"likes": 586,
"date": "November 26, 2021"
},
{
"title": "matthew baxter",
"avatar": "https://play-lh.googleusercontent.com/a/AATXAJy9NbOSrGscHXhJu8wmwBvR4iD-BiApImKfD2RN=mo",
"rating": 1,
"snippet": "App is broken, every video shows no dislikes even after I hit the button. I've tested this with multiple videos and now my recommended is all messed up because of it. The ads are longer than the videos that I'm trying to watch and there is always a second ad after the first one. This app seriously sucks. I would not recommend this app to anyone.",
"likes": 352,
"date": "November 28, 2021"
},
{
"title": "Operation Blackout",
"avatar": "https://play-lh.googleusercontent.com/a-/AOh14GjMRxVZafTAmwYA5xtamcfQbp0-rUWFRx_JzQML",
"rating": 2,
"snippet": "YouTube used to be great, but now theyve made questionable and arguably stupid decisions that have effectively ruined the platform. For instance, you now have the grand chance of getting 30 seconds of unskipable ad time before the start of a video (or even in the middle of it)! This happens so frequently that its actually a feasible option to buy an ad blocker just for YouTube itself... In correlation with this, YouTube is so sensitive twords the public they decided to remove dislikes. Why????",
"likes": 370,
"date": "November 24, 2021"
},
...
],
"serpapi_pagination": {
"next": "https://serpapi.com/search.json?all_reviews=true&engine=google_play_product&gl=us&hl=en&next_page_token=CpEBCo4BKmgKR_8AwEEujFG0VLQA___-9zuazVT_jmsbmJ6WnsXPz8_Pz8_PxsfJx5vJns3Gxc7FiZLFxsrLysnHx8rIx87Mx8nNzsnLyv_-ECghlTCOpBLShpdQAFoLCZiJujt_EovhEANgmOjCATIiCiAKHmFuZHJvaWRfaGVscGZ1bG5lc3NfcXNjb3JlX3YyYQ&product_id=com.google.android.youtube&store=apps",
"next_page_token": "CpEBCo4BKmgKR_8AwEEujFG0VLQA___-9zuazVT_jmsbmJ6WnsXPz8_Pz8_PxsfJx5vJns3Gxc7FiZLFxsrLysnHx8rIx87Mx8nNzsnLyv_-ECghlTCOpBLShpdQAFoLCZiJujt_EovhEANgmOjCATIiCiAKHmFuZHJvaWRfaGVscGZ1bG5lc3NfcXNjb3JlX3YyYQ"
}

有关更多详细信息,请查看文档。

在操场上实时测试搜索。

免责声明:我在SerpApi工作。

您可以考虑使用 SearchApi,特别是 Google Play Product API。此 API 提供详细的产品信息,首页返回 40 条评论。后续页面每个请求可以产生超过 4000 条评论。

下面是一个简单的 Python 代码片段,说明了如何从 TikTok 应用程序中检索 2000 条评论:

import requests
payload = {
'api_key': 'key',               # key is received upon registration.
'engine': 'google_play_product',
'store': 'apps',
'product_id': 'com.zhiliaoapp.musically',
'num': '2000',
'next_page_token': 'CnIKcApuMCwxMDAxMDAwLjc0NjM2MzUyMDYsODQ3MzU0MzQ3NTg3LCJodHRwOi8vbWFya2V0LmFuZHJvaWQuY29tL2RldGFpbHM_aWQ9djI6Y29tLnpoaWxpYW9hcHAubXVzaWNhbGx5OjEiLDEsZmFsc2U'
}
response = requests.get('https://www.searchapi.io/api/v1/search', params=payload)
print(response.text)

以下是 3 条评论的 JSON 示例:

{
"reviews": [
{
"id": "ce3c3d5d-0138-44c7-a980-617270b022ac",
"product_version": "29.3.4",
"username": "Abby",
"avatar": "https://play-lh.googleusercontent.com/a/AAcHTtfTZo0ehDfPzsn68ifvszx0WFwQ1gRsm-5y3lFwPrCJ=mo",
"rating": 4,
"link": "https://play.google.com/store/apps/details?id=&reviewId=ce3c3d5d-0138-44c7-a980-617270b022ac",
"text": "Honestly, I think tiktok is a very good app and it is also really fun to do dances find songs you really like. You could even connect with some people. I just think it's a very good app! There's so much more to it. You can cooking recipes, life hacks. Some stuff can be false. That's the only bad thing over all. I really really love the app!",
"likes": 610,
"date": "May 10, 2023"
},
{
"id": "f3cb1893-bb89-43c5-a9c2-d2e814be9add",
"product_version": "29.5.4",
"username": "Dr3amwalker",
"avatar": "https://play-lh.googleusercontent.com/a-/AD_cMMQJUo-A3fxIceFTdQGr1ejTGvAxrpxae9HSo3Sl02cMECs",
"rating": 5,
"link": "https://play.google.com/store/apps/details?id=&reviewId=f3cb1893-bb89-43c5-a9c2-d2e814be9add",
"text": "Edited review:: I've used TikTok quite a bit, and while there ARE parts of tiktok that I dont like, or parts that may be problematic, the app itself is great for what it is. It's taught me things I never thought I'd know. It's helped with making me feel less isolated. - Disclaimer: Moderation is key. Learn how the algorithm works [its super easy] and you can tailor your experience near perfectly.",
"likes": 1272,
"date": "May 17, 2023"
},
{
"id": "54efe07b-2cb5-4716-98e4-7735d036ce28",
"product_version": "29.5.5",
"username": "owns 7 hats",
"avatar": "https://play-lh.googleusercontent.com/a-/AD_cMMTgpgkOR7dJZ2S5y6JsDIApQuPQy91QqaMfKtqFFhVqMyCO",
"rating": 1,
"link": "https://play.google.com/store/apps/details?id=&reviewId=54efe07b-2cb5-4716-98e4-7735d036ce28",
"text": "Recent update with text and picture slides is obnoxious. Can't pause the sound without a pop up that glitches out way too badly. Not to mention the series feature, when there's a part 2,3,4 or whatever the Playlist shouldn't be playing the most recent episode first. You don't watch a movie backwards and the autoplay prevents you from seeing it in the right order almost entirely with how annoying it is. I'm about to delete the app because these features are not worth my time.",
"likes": 671,
"date": "May 17, 2023"
}
]
}

您可以在此处找到 Google Play 产品 API 的文档:https://www.searchapi.io/docs/google-play-product

免责声明:我为SearchApi工作。

最新更新