egirault / googleplay-api

Google Play Unofficial Python API - This project was a PoC and is not maintained anymore. Please feel free to fork it and improve it in any way.
877 stars 373 forks source link

offset seems to be broken in list.py #48

Open tbwolfe opened 9 years ago

tbwolfe commented 9 years ago

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:

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

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

anands commented 9 years ago

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

@egirault Any fix for this?

MikhailAOstapenko commented 9 years ago

Same problem here. Google changed API?

gowthamgts commented 8 years ago

Yeah, I'm also experiencing the same problem.

ycheng-sec commented 8 years ago

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?

mylh commented 7 years ago

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
  }
p3r1c0 commented 6 years ago

someone fix this problem?

P-Sc commented 6 years ago

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.

sehring commented 6 years ago

@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.

P-Sc commented 6 years ago

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