Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mapping for app listing #547

Closed
wants to merge 9 commits into from
Closed

Conversation

weizenberg
Copy link

No description provided.

@facundoolano
Copy link
Owner

What's the difference with #545?

@weizenberg
Copy link
Author

It's missed the mapping for the 'search' method. I pulled from #545 and fixed the specific mapping.

@Alexays
Copy link

Alexays commented May 30, 2022

@weizenberg it misses the fact of handling the enriched results, like facebook first result here
e.g. https://play.google.com/store/search?q=facebook&c=apps

@ninjachen
Copy link

Hello @weizenberg , I used your PR by
"google-play-scraper": "git+https://github.com/facundoolano/google-play-scraper#pull/547/head"

but I still can not use the list function. These are the steps I use

npm ci --include=dev
npx functions-framework --target=list
open a Chrome to http://localhost:8080/scraper-list?collection=topselling_free&country=us&from=0&limit=150

I failed with an error called

Error: Invalid collection topselling_new_free
    at validate (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:43:11)
    at /Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:14:5
    at new Promise (<anonymous>)
    at Object.list (/Users/ninja/src/lab/scraper/node_modules/google-play-scraper/lib/list.js:13:10)
    at exports.list (/Users/ninja/src/lab/scraper/index.js:31:15)
    at /Users/ninja/src/lab/scraper/node_modules/@google-cloud/functions-framework/build/src/invoker.js:98:17
    at processTicksAndRejections (node:internal/process/task_queues:76:11)

Could you help on this list function?

@ChayaGel
Copy link

ChayaGel commented Jun 2, 2022

It works me for search,
but some of the searches returns [], and I found why:
in the new UI, when google play find 1 spesific app that very suitable to the search term,
they show this app big and then the other results as "more results".
(exapmle: https://play.google.com/store/search?q=waze&c=apps&hl=en&gl=us vs https://play.google.com/store/search?q=bank&c=apps&hl=en&gl=us)
Such a situation must also be mapped.
now it returns [].

I dont know how to fix the mapping, but at least I found the point.
can someone do it?

@adtimizer
Copy link

adtimizer commented Jun 6, 2022

@weizenberg Thanks for the PR. i'm trying to work with it but when the package name is incorrect it fails with a nasty error

for example
gplay.app({ appId: "com.i2dllc.keymastermac",country:"us"}).then(console.log, console.log);
shows the following:

(node:33497) UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found)
    at Request.request.once (/Users/orenbaranes/Adtimizer/Repo/gplay/node_modules/got/dist/source/as-promise/index.js:119:42)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:33497) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:33497) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

in the past it was returning an error of app not found 404.
can you help figure out what went wrong?

@andrew-curry
Copy link

I used this pr but the gplay.list() returns [], anyone know how to deal with it?

@weizenberg
Copy link
Author

weizenberg commented Jun 7, 2022

Hey folks,

Thank you for reviewing the commit.
I'm a bit busy these days, but I think I will be able to solve most of the issues here in the following week. I appreciate your patience!

Anyway, I see someone here developed a tool that helps to map the results into the arrays, you can try to find it and make use of it to solve the issues.

@ChayaGel Thank you mate! I also got this specific issue but couldn't understand why! Now I know how to solve it, so thanks for that.

PS - @ninjachen This fix is related only to the search method, not list method.

When searching for terms like 'waze', the new Google UI presenting
different page (ex: https://play.google.com/store/search?q=waze&c=apps)
with 'More results' section. This commit solved this issue by
looking for more results in case that 'normal' results not received.

I build a generic method to look for the results data, because sometimes
the path changed between the terms, this why I added tests for 'waze'
and 'clash of clans' who returns different "More results" paths.

I also fixed the batch query request data (which fetched manually) using
a token and request data provided in 'data' directory.
@weizenberg
Copy link
Author

Hey folks!

Finally found some time to fix this issue. I am glad to share the fix with you.
As I mentioned in the commit, I found that different terms may return different paths for the results, and this is why I made this a generic method for a recursive looking into the results.

I assumed that the app array should be more than 100, but maybe we can adjust this later to ensure it will fit any future updates. Fill free to use this method in the other parts of the library as it will make it easier to find the arrays you looking for.

Fixed token in case of 'normal' term
@ChayaGel
Copy link

This new mapping is excellent,
But it skips the "most appropriate" option for the search result ...!
We would expect that in case there is a particularly suitable one app, the function will return it first in the array and only after that will be added "more results"

thanks

@Aliaksandr-Kasko-JazzTeam
Copy link
Contributor

gplay.list() method still returns an empty array

@weizenberg
Copy link
Author

This new mapping is excellent, But it skips the "most appropriate" option for the search result ...! We would expect that in case there is a particularly suitable one app, the function will return it first in the array and only after that will be added "more results"

thanks

Thank you, I added a check for the 'root' app type and added appropriate mapping. Check the recent commit.

gplay.list() method still returns an empty array

As I mentioned before, this fix applies only to the search method. You're more than welcome to add the same mapping function to other methods as well.

@facundoolano
Copy link
Owner

Closing this as it should be fixed by #557

@KaKi87
Copy link

KaKi87 commented Jun 23, 2022

Hello,

Search works again, thanks !

However, why am I getting much less results than before ?
For example, search({ term: 'web browser', num: 250 }) outputs 10 items.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants