Warm tip: This article is reproduced from serverfault.com, please click

android-爬行的Google Play商店应用

(android - Crawling Google Play Store Apps)

发布于 2018-09-03 14:22:35

我想抓取Google Play商店并获取特定类别的所有应用ID。当我执行以下代码时,我得到的前49个应用程序的应用程序ID不超过此。但我想获取所有应用程序ID。我怎样才能做到这一点?我使用的网址是https://play.google.com/store/search?q=sports&c=apps&hl=zh_CN进行抓取。

import urllib.request, urllib.error, urllib.parse
from bs4 import BeautifulSoup

url=input('Enter:')
html=urllib.request.urlopen(url).read()
soup=BeautifulSoup(html,'html.parser')

tags=soup('a')
l=list()
for tag in tags:
    x=tag.get('href',None)
    if x.find("/store/apps/details?id=")!=-1:
       if not(x[23:] in l):
            l.append(x[23:])
print(l)
Questioner
Darshil
Viewed
11
Jakub Balada 2018-09-04 20:01:06

在这样的动态站点上,最好使用内部XHR获取数据而不是解析html。每个显示的48个应用都有一个POST请求,你可以从脚本中调用该请求。在此博客文章中,举例说明了如何以这种方式从Google Play商店获得应用评论。