pat310 / google-trends-api

An API layer on top of google trends
https://www.npmjs.com/package/google-trends-api
MIT License
877 stars 175 forks source link

Unexpected token L in JSON at position 0 #97

Closed mlegocki closed 6 years ago

mlegocki commented 6 years ago

I know this issue has been resolved in the past but it seems it has resurfaced for me at least. This library was working a few weeks ago (@version 4.4.0) however now with the latest version I can't make any calls with the same code. It seems that Google is flagging these calls as 'automated' and unusual traffic. Any tips on getting past this? I'm signed into google and have tried this using both Chrome and Firefox.

Using the latest version of node (9.6.1) and npm (5.6.0)

SPECIFIC ERROR BELOW: { SyntaxError: Unexpected token L in JSON at position 0 at JSON.parse () at a (/Users/MLegocki/FullStack/Projects/CryptoTrends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:2976) at /Users/MLegocki/FullStack/Projects/CryptoTrends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:3887 at at process._tickCallback (internal/process/next_tick.js:160:7) requestBody: '\n302 Moved\n

302 Moved

\nThe document has moved\nhere.\r\n\r\n' }

pat310 commented 6 years ago

Thanks I'll check it out 🤔

mlegocki commented 6 years ago

It appears to be working again! The same code is now going through....weird that it was temporary. I'm on the same IP/network as well so I really don't have an explanation for why it wasn't working.

Thank you for looking into it! I'll keep you posted if it arises again.