使用python获取Google Playstore应用下载链接

时间:2018-01-27 22:50:00

标签: android python search beautifulsoup

我想获取特定类别的每个应用的Playstore链接。

以下是我的尝试:

r = br.open("https://play.google.com/store/apps/category/ART_AND_DESIGN/collection/topselling_free")
html = r.read()
soup = bsoup(html)

urlslist = soup.findAll("a", { "class" : "card-click-target" })

fo = open('url.txt', 'w')

for url in urlslist:
        print "".join(["https://play.google.com",url])
        fo.write("".join(["https://play.google.com",url])+"\n")

fo.close()

但它不会返回任何东西。 urlslist也没有填充。我试过不同的标签和类,例如。 soup.findAll("div", { "class" : "title" }),但这也会返回一个空白数组。

请指教。提前谢谢。

1 个答案:

答案 0 :(得分:5)

你必须迭代:

  

soup.findAll(" a",{" class":" card-click-target"})

然后提取每个href标记的a属性

因此请更改以下代码:

for url in urlslist:
    print "".join(["https://play.google.com",url])
    fo.write("".join(["https://play.google.com",url])+"\n")

要:

for a in urlslist:
    link = "https://play.google.com" + a['href']
    print(link)
    fo.write(link + "\n")