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

TypeError: Cannot read properties of undefined (reading 'map') when using .search() #613

Open
bulgarian-beast opened this issue Jan 9, 2023 · 8 comments

Comments

@bulgarian-beast
Copy link

This issue have been tested on the official node Dockerfile, and a MacOS.

  • Operating System: Got the error using a docker image FROM node and a MacOS 13.0.1
  • Node version: v18.11.0
  • google-play-scraper version: "google-play-scraper": "^9.1.0"

Description:

Got a TypeError: Cannot read properties of undefined (reading 'map') when using .search()

Example Dockerfile:

FROM node

EXPOSE 3000

WORKDIR /app

COPY . .

RUN npm install

CMD node server.js

Example code:

const gplay = require('google-play-scraper');

gplay.search(
  {
    term: 'social',
    lang: 'fr',
    country: 'FR',
    num: 5
  }
  )
  .then((apps) => { console.log(apps) })
  .catch((error) => {
    console.log(error);
  });

Error message:

TypeError: Cannot read properties of undefined (reading 'map')
    at node_modules/ramda/dist/ramda.js:578:31
    at Object.f2 [as map] (node_modules/ramda/dist/ramda.js:473:22)
    at processFirstPage (node_modules/google-play-scraper/lib/search.js:101:27)
    at node_modules/google-play-scraper/lib/search.js:31:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@bulgarian-beast
Copy link
Author

It looks like it's related to: country: 'FR', because when I put: country: 'US', it works.

Hoping it will help.

@degola
Copy link

degola commented Jan 31, 2023

I have the same issue with this request and it seems to be a language issue but we'd love to scrape different languages:

const gplay = require('google-play-scraper')
await gplay.search({
  term: 'escacs',
  country: 'es',
  lang: 'ca',
  num: 200,
  fullDetail: true
})

There seems to be something wrong with the parsing in search.js:101, so far I came to the point that moreResultsSection is undefined/null in line https://github.com/facundoolano/google-play-scraper/blob/main/lib/search.js#L98.

I'm not familiar with Ramda and how its supposed to work to find a corresponding patch quickly, maybe someone else has an idea?

@degola
Copy link

degola commented Jan 31, 2023

The unit tests fail on search as well, it looks like the parsing breaks especially if/when there are less than 30 apps for a search result.

@KaKi87
Copy link

KaKi87 commented Feb 1, 2023

A playsearch.kaki87.net user discovered that failing single-word queries may be fixed by adding quotes, possibly due to the following layout change they captured :

netgear "netgear"

when I put: country: 'US', it works.

Not universal, unfortunately.

For example, when term = netgear, then US won't work, while FR & ES do.

@degola
Copy link

degola commented Feb 1, 2023

Interesting, that seems to work indeed, just putting the term in quotes ' seems to work for all countries (at least not yet found a keyword which doesn't work). Probably just a temporarily solution but better than nothing :-).

@KaKi87
Copy link

KaKi87 commented Feb 1, 2023

Well, it only works when searching apps by title, it won't work with generic terms like "web browser" for example.

@jbigman
Copy link
Contributor

jbigman commented Aug 3, 2023

I checked both

await gplay.search({
  term: 'escacs',
  country: 'es',
  lang: 'ca',
  num: 200,
  fullDetail: true
})

await gplay.search({
  term: 'social',
  lang: 'fr',
  country: 'FR',
  num: 5
})

Seems to be corrected with last merged PRs

@londonadagio
Copy link

londonadagio commented Apr 25, 2024

I think I have a similar or related issue. I isolated it to a single keyword that doesn't appear to work.

If I try this request with v10.0.0 of the library :

import gplay from "google-play-scraper";

gplay.search({
    term: 'Viulunvirittäjä',
}).then(r => {
    console.log(r)
})

Then I get this error :

file:///blabla/node_modules/ramda/es/internal/_dispatchable.js:31
        if (typeof obj[methodNames[idx]] === 'function') {
                      ^

TypeError: Cannot read properties of undefined (reading 'fantasy-land/map')
    at file:///blabla/node_modules/ramda/es/internal/_dispatchable.js:31:23
    at Module.f2 (file:///blabla/node_modules/ramda/es/internal/_curry2.js:28:14)
    at processFirstPage (file:///blabla/node_modules/google-play-scraper/lib/search.js:99:27)
    at file://blabla/node_modules/google-play-scraper/lib/search.js:29:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.10.0

I tried a bunch of options (notably in terms of country and language but also throttling, number of results etc...) and nothing worked. Funnily enough searching for "Viulun virittäjä" does work perfectly.

I also tried the quote trick from above to no avail.

I'm wondering if this could be due to the play store returning zero result for that specific request (see here : https://play.google.com/store/search?q=Viulunviritt%C3%A4j%C3%A4&c=apps ), so I wanted to try finding another request with no result but I couldn't find a single one. Even entering a bunch of gibberish the Play Store would still give me some result.

The issue is that it's completely breaking the script I'm using, and I haven't managed to work around it apart from finding the bad keyword and specifically excluding it from my script. Any help?

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

No branches or pull requests

5 participants