GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.28k stars 821 forks source link

Running example code. #150

Closed vpolimenov closed 7 years ago

vpolimenov commented 7 years ago

Just came across this. Great stuff btw 🥇

However, I am getting the following error when I try to run: trending_searches_df = pytrends.trending_searches()

---------------------------------------------
JSONDecodeErrorTraceback (most recent call last)
<ipython-input-27-5c9ffd459706> in <module>()
      1 # Get Google Hot Trends data
----> 2 trending_searches_df = pytrends.trending_searches()
      3 # trending_searches_df.head()

/Users/ventsislav/anaconda/envs/py3/lib/python3.6/site-packages/pytrends/request.py in trending_searches(self)
    199         forms = {'ajax': 1, 'pn': 'p1', 'htd': '', 'htv': 'l'}
    200         req = self.ses.post(req_url, data=forms)
--> 201         req_json = json.loads(req.text)['trendsByDateList']
    202         result_df = pd.DataFrame()
    203 

/Users/ventsislav/anaconda/envs/py3/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    352             parse_int is None and parse_float is None and
    353             parse_constant is None and object_pairs_hook is None and not kw):
--> 354         return _default_decoder.decode(s)
    355     if cls is None:
    356         cls = JSONDecoder

/Users/ventsislav/anaconda/envs/py3/lib/python3.6/json/decoder.py in decode(self, s, _w)
    337 
    338         """
--> 339         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    340         end = _w(s, end).end()
    341         if end != len(s):

/Users/ventsislav/anaconda/envs/py3/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
    355             obj, end = self.scan_once(s, idx)
    356         except StopIteration as err:
--> 357             raise JSONDecodeError("Expecting value", s, err.value) from None
    358         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I figured out you might have an idea ? 🙄

dreyco676 commented 7 years ago

Looks like you are on an old version. I'd recommend pulling down the newest and reopen if issue persists.