isopach
isopach

Reputation: 1928

Get Google Playstore app download links with python

I want to get the Playstore links of each app of a particular category.

Here's what I have tried:

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

But it doesn't return anything. urlslist is not populated either. I have tried with different tags and classes eg. soup.findAll("div", { "class" : "title" }), but that also returns a blank array.

Please advise. Thank you in advance.

Upvotes: 3

Views: 1174

Answers (1)

zamir
zamir

Reputation: 2522

You have to iterate over:

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

Then extract href attribute of each a tag,

So change the following code:

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

To:

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

Upvotes: 5

Related Questions