Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

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

Open
@RasmusFonseca

Description

@RasmusFonseca

Running the minimal example crashes with an error:

$ ipython
Python 3.8.3 (default, May 19 2020, 13:54:14) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from twitter_scraper import get_tweets                                                                                        

In [2]: for tweet in get_tweets('twitter', pages=1): 
   ...:     print(tweet['text']) 
   ...:                                                                                                                               
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-2-bd0d769d18f8> in <module>
----> 1 for tweet in get_tweets('twitter', pages=1):
      2     print(tweet['text'])
      3 

~/opt/miniconda3/lib/python3.8/site-packages/twitter_scraper-0.4.3-py3.8.egg/twitter_scraper/modules/tweets.py in get_tweets(query, pages)
    169             pages += -1
    170 
--> 171     yield from gen_tweets(pages)
    172 
    173 

~/opt/miniconda3/lib/python3.8/site-packages/twitter_scraper-0.4.3-py3.8.egg/twitter_scraper/modules/tweets.py in gen_tweets(pages)
     34         while pages > 0:
     35             try:
---> 36                 json_response = request.json()
     37                 html = HTML(
     38                     html=json_response["items_html"], url="bunk", default_encoding="utf-8"

~/opt/miniconda3/lib/python3.8/site-packages/requests/models.py in json(self, **kwargs)
    896                     # used.
    897                     pass
--> 898         return complexjson.loads(self.text, **kwargs)
    899 
    900     @property

~/opt/miniconda3/lib/python3.8/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    355             parse_int is None and parse_float is None and
    356             parse_constant is None and object_pairs_hook is None and not kw):
--> 357         return _default_decoder.decode(s)
    358     if cls is None:
    359         cls = JSONDecoder

~/opt/miniconda3/lib/python3.8/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

~/opt/miniconda3/lib/python3.8/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions