googleplay-api icon indicating copy to clipboard operation
googleplay-api copied to clipboard

Unable to continue search on next page

Open kallix opened this issue 5 years ago • 2 comments

Hi,

When using api.search(), the last child has a relatedLinks item that contains a nextPageUrl element with a link.

However, the api does not offer any way (that I know of) to follow this link.

Am I missing something ? Can something like that be implemented in googleplay-api ?

kallix avatar May 20 '20 15:05 kallix

It seems that calling self.executeRequestApi2(FDFE + nextPageUrl) indeed gives some more results

kallix avatar May 20 '20 15:05 kallix

This bit of code will collect all the apps and allow you continue on to the next page

from gpapi.googleplay import GooglePlayAPI
from gpapi import googleplay as gp
from gpapi import utils

api = GooglePlayAPI(...)
apps = []
result = api.search(<query>) #whatever the search query is
while result:
    for doc in result:
	if 'docid' in doc:
            sub_res.append(doc["docid"])
	for cluster in doc["child"]:
            for app in cluster["child"]:
                apps.append(app)
            if 'containerMetadata' in cluster and 'nextPageUrl' in cluster["containerMetadata"]:
                nextPageUrl = cluster["containerMetadata"]['nextPageUrl']
		response = api.executeRequestApi2(gp.FDFE + nextPageUrl)
                next_result = list(map(utils.parseProtobufObj,response.payload.listResponse.doc))
            else:
                next_result = None
    result = next_result

for app in apps: 
    print(apps["backendDocid'])

If I have time, I'll create a pull request for an option to get all the results in search()

adamaviv avatar Jul 02 '20 19:07 adamaviv