facundoolano / google-play-scraper

Node.js scraper to get data from Google Play
MIT License
2.32k stars 629 forks source link

Error: Error requesting Google Play:Cannot read property 'startsWith' of undefined #503

Open nottoobad opened 2 years ago

nottoobad commented 2 years ago

Description:

Import 'https-proxy-agent' will cause 'google-play-scraper' throw the exception: Error: Error requesting Google Play:Cannot read property 'startsWith' of undefined

Example code:

// Put code to reproduce the issue here
var HttpsProxyAgent = require('https-proxy-agent'); //comment this line, code below will work.
var gplay = require('google-play-scraper');
gplay.app({appId: 'cc.pacer.androidapp'})
  .then(console.log, console.log);

Error message:

{ Error: Error requesting Google Play:Cannot read property 'startsWith' of undefined
    at D:\google-play-scraper-pg\node_modules\google-play-scraper\lib\utils\request.js:41:19
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) status: undefined }
VitaliyRDev commented 2 years ago

Check this instruction: https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying

facundoolano commented 2 years ago

If I recall correctly you can pass a requestOptions field to all the methods. This is passed over to the underlying request library, currently got: check this for proxy support.

If you figure out an example please share here.