alex9smith / gdelt-doc-api

A Python client for the GDELT 2.0 Doc API
MIT License
100 stars 23 forks source link

Another JSONDecodeError #28

Open FishStick438 opened 1 year ago

FishStick438 commented 1 year ago

For a specific date and specific keyword, an error occurs, while using the direct GDELT API has no issues. Below is my code and error message.

Thanks for the help!

gd = GdeltDoc()

f = Filters(
    keyword = "carbon neutrality",
    start_date = "20230201",
    end_date = "20230202",
    num_records = 250
)

articles = gd.article_search(f)
JSONDecodeError                           Traceback (most recent call last)
[c:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\gdeltdoc\helpers.py](file:///C:/Users/User/AppData/Local/Programs/Python/Python37/lib/site-packages/gdeltdoc/helpers.py) in load_json(json_message, max_recursion_depth, recursion_depth)
     14     try:
---> 15         result = json.loads(json_message)
     16     except Exception as e:

[c:\Users\User\AppData\Local\Programs\Python\Python37\lib\json\__init__.py](file:///C:/Users/User/AppData/Local/Programs/Python/Python37/lib/json/__init__.py) in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    347             parse_constant is None and object_pairs_hook is None and not kw):
--> 348         return _default_decoder.decode(s)
    349     if cls is None:

[c:\Users\User\AppData\Local\Programs\Python\Python37\lib\json\decoder.py](file:///C:/Users/User/AppData/Local/Programs/Python/Python37/lib/json/decoder.py) in decode(self, s, _w)
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()

[c:\Users\User\AppData\Local\Programs\Python\Python37\lib\json\decoder.py](file:///C:/Users/User/AppData/Local/Programs/Python/Python37/lib/json/decoder.py) in raw_decode(self, s, idx)
    352         try:
--> 353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:

JSONDecodeError: Invalid \escape: line 1 column 13566 (char 13565)

During handling of the above exception, another exception occurred:
...
---> 18             raise ValueError("Max Recursion depth is reached. JSON can´t be parsed!")
     19         # Find the offending character index:
     20         idx_to_replace = int(e.pos)

ValueError: Max Recursion depth is reached. JSON can´t be parsed!