python - 如何获取/抓取 Play 商店或应用商店中应用的所有评论,我只获得前 40 条评论?

标签 python web-scraping google-play scrapy web-crawler

我正在为此使用 python。 我要播放一个应用程序的商店 url,然后将正文解析为树,使用 xpath 提取数据

reviews = parsed.xpath('//div[@class="single-review"]//div[@class="review-body with-review-wrapper"]')

然后将其写入文件

reviewFile = rev.sub('[^A-Za-z0-9.,\' ]+', '', reviewFile.text_content().replace('  Full Review  ','').strip())
    print('writing reviewFile'+reviewFile)

但有了这个,我只能在 Google Play 商店中获得前 40 条评论,而不是所有评论。

在显示前 40 条评论后,Google Play 开始通过 ping 命令加载更多评论 http://play.google.com/store/getreviews

最佳答案

您必须发送一个帖子请求到https://play.google.com/store/getreviews .发布请求必须包含以下 header :

headers = {
  'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
}

您的查询(页码、评论排序等)应该是一个 urlencoded 字符串,例如:

payload = 'reviewType=0&pageNum=' + pagenum + '&id=' + appid + '&reviewSortOrder=2&xhr=1'

然后您可以使用请求模块发送此请求:

text = requests.post(url, data=payload, headers=headers).text

注意: 响应实际上是一个列表的形式,其中包含您必须解析的 html,并且它有这个奇怪的 )]}' 东西在开始时你将不得不摆脱。

关于python - 如何获取/抓取 Play 商店或应用商店中应用的所有评论,我只获得前 40 条评论?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37400336/

相关文章:

python - 如何优化 Python 例程以对图像中的所有像素进行颜色匹配?

python - 网页抓取 bs4,无法弄清楚如何获得结果

android - Google Play 电子邮件回复。通话/短信日志权限?

python - 使用 DataFrame 绘制双轴图

python - 使用 MultiIndex 和多列从 DataFrame 中绘制和注释

python - numpy.int64 和/或 numpy.float64 的奇怪基本计算问题?

python - BeautifulSoup 在 Python 中抓取 itemprop ="name"

api - 从网站上抓取数据的最佳方式是什么?

android - 我可以在保留私钥的同时更改 Android 签名证书主题吗

react-native - 如何安装 React Native 应用程序而不将其发布到任何商店?