我想抓取Google Play商店并获取特定类别的所有应用ID。当我执行以下代码时,我得到的前49个应用程序的应用程序ID不超过此。但我想获取所有应用程序ID。我该如何实现?
我使用的URL是https://play.google.com/store/search?q=sports&c=apps&hl=en进行抓取。
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)
最佳答案
在这样的动态站点上,最好使用内部XHR获取数据而不是解析html。每个显示的48个应用都有一个POST请求,您可以从脚本中调用该请求。 In this blog post是如何以这种方式从Google Play商店获取应用评论的示例。
关于android - 爬行的Google Play商店应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52151644/