【问题标题】:Get Google Playstore app download links with python使用 python 获取 Google Play Store 应用下载链接
【发布时间】:2018-01-27 22:49:59
【问题描述】:

我想获取特定类别的每个应用的 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" }),但这也返回一个空白数组。

请指教。提前谢谢你。

【问题讨论】:

    标签: android python search beautifulsoup


    【解决方案1】:

    你必须迭代:

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

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

    所以修改如下代码:

    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")
    

    【讨论】:

    • 谢谢! urlslist 仍然返回一个空数组,知道为什么吗?
    • @Yuu 有没有html = r.read() 给你页面源代码?因为在这里我用requests库测试了
    • 是的,确实如此。用 requests 库怎么写?
    • requests.get(url).text 会给你源代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-12
    • 1970-01-01
    • 1970-01-01
    • 2013-12-08
    相关资源
    最近更新 更多