AnthonyBloomer / daftlistings

A library that enables programmatic interaction with daft.ie. Daft.ie has nationwide coverage and contains about 80% of the total available properties in Ireland.
MIT License
171 stars 54 forks source link

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #165

Closed aaronpkelly closed 11 months ago

aaronpkelly commented 1 year ago

Downloaded this repo a few days ago and it worked great, all the examples were working fine

However, yesterday, I tried to run the first example you give in your README.md (properties_for_rent.py), and I get this error:

Searching...
Traceback (most recent call last):
  File "/Users/aaronkelly/src/dafty/.venv/lib/python3.12/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aaronkelly/.nix-profile/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aaronkelly/.nix-profile/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aaronkelly/.nix-profile/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aaronkelly/src/dafty/example_1.py", line 8, in <module>
    listings = daft.search()
               ^^^^^^^^^^^^^
  File "/Users/aaronkelly/src/dafty/.venv/lib/python3.12/site-packages/daftlistings/daft.py", line 252, in search
    listings = r.json()["listings"]
               ^^^^^^^^
  File "/Users/aaronkelly/src/dafty/.venv/lib/python3.12/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is frustrating because your library was working fine up until a couple of days ago.

Can you reproduce this?

sdfordham commented 1 year ago

The problem is the endpoint is giving a 403 response and so obviously no json to decode. This is on the daft side not on our side. We will need to see if this has broken the package completely @AnthonyBloomer.

EDIT: discussion here #166.

AnthonyBloomer commented 11 months ago

v2.0.4 is now on PyPi with @sdfordham fix: https://pypi.org/project/daftlistings/2.0.4/