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

offset seems to be broken in list.py

Open tbwolfe opened this issue 10 years ago • 9 comments

The offset seems to be broken in the list.py functionality. See snippets below for example:

The first request should return results 1-5 of the app selling free apps in the business category:

  • $ python list.py BUSINESS apps_topselling_free 5 0
    Title;Package name;Creator;Super Dev;Price;Offer Type;Version Code;Size;Rating;Num Downloads
    Job Search;com.indeed.android.jobsearch;Indeed Jobs;0;Free;1;19;1.7MB;4.02;10,000,000+
    Facebook Pages Manager;com.facebook.pages.app;Facebook;1;Free;1;9490210;27.1MB;4.13;10,000,000+
    ADP Mobile Solutions;com.adpmobile.android;ADP, LLC;0;Free;1;47;6.1MB;3.97;1,000,000+
    Square Register;com.squareup;Square, Inc.;0;Free;1;365;26.1MB;4.52;5,000,000+
    Job Search - Snagajob;com.snagajob.jobseeker;Snagajob;0;Free;1;42;9.1MB;3.90;1,000,000+

The second request should return apps 6-10 of the same category, but the results are identical.

  • $ python list.py BUSINESS apps_topselling_free 5 5
    Title;Package name;Creator;Super Dev;Price;Offer Type;Version Code;Size;Rating;Num Downloads Job Search;com.indeed.android.jobsearch;Indeed Jobs;0;Free;1;19;1.7MB;4.02;10,000,000+
    Facebook Pages Manager;com.facebook.pages.app;Facebook;1;Free;1;9490210;27.1MB;4.13;10,000,000+
    ADP Mobile Solutions;com.adpmobile.android;ADP, LLC;0;Free;1;47;6.1MB;3.97;1,000,000+
    Square Register;com.squareup;Square, Inc.;0;Free;1;365;26.1MB;4.52;5,000,000+ Job Search - Snagajob;com.snagajob.jobseeker;Snagajob;0;Free;1;42;9.1MB;3.90;1,000,000+

This query was constructed from the documentation presented in the project wiki (https://github.com/egirault/googleplay-api/blob/master/README.md).

tbwolfe avatar May 22 '15 19:05 tbwolfe

Hey @tbwolfe , Any Update on this? I've facing the same problem.

@egirault Any fix for this?

anands avatar Jun 03 '15 09:06 anands

Same problem here. Google changed API?

MikhailAOstapenko avatar Jul 05 '15 06:07 MikhailAOstapenko

Yeah, I'm also experiencing the same problem.

gowthamgts avatar Jul 27 '15 09:07 gowthamgts

I'm also facing the same problem. I can see the URL with offset configured has a field "&o=xxx". But it won't work. Does anyone know what the parameter could be?

ycheng-sec avatar Dec 15 '15 01:12 ycheng-sec

Looks like google added a new parameter named "ctntkn" into query string. But you shouldn't guess its value, just use nextPageUrl returned from top page request result and any subsequent result:

containerMetadata {
    browseUrl: "browse?bt=4&c=3&ctr=apps_topselling_free&cat=GAME"
    nextPageUrl: "list?bt=4&c=3&ctr=apps_topselling_free&cat=GAME&n=20&ctntkn=CBQ%3D&o=20"
    analyticsCookie: "578096662"
    ordered: true
  }

mylh avatar Aug 24 '16 17:08 mylh

someone fix this problem?

p3r1c0 avatar Jul 24 '17 17:07 p3r1c0

I have somehow figured out (through trial and error) how to get the correct "ctntkn" value without using nextPageUrl:


import string
import requests

code="AEIMQUYcgkosw048"
code_suffix="=BCDEFGHIJKLMNOPQRSTUVWXYZ"

def get_token(offset):
    if offset >= 254:
        offset += 1
    i = offset // 16
    j = offset % 16
    s = offset // 128
    if s > 0:
        i -= 8 * (s-1)
    key = string.ascii_uppercase[i] + code[j]
    token = "C" + key + requests.utils.quote(code_suffix[s])
    return token

So inserting the function in googleplay.py and appending path += "&ctntkn=" + get_token(int(offset)) after this line should make it work again.

P-Sc avatar Dec 17 '17 23:12 P-Sc

@P-Sc This approach does not work anymore. It gets stuck at page 5. You have to call the value of "nextPageUrl:" and make sure to use this url as path.

sehring avatar Apr 24 '18 17:04 sehring

You get stuck at page 5 either way because there is no "nextPageUrl" after 500 apps. Google simply doesn't allow more than that to be queried (per category).

P-Sc avatar Apr 24 '18 19:04 P-Sc