yasserqureshi1 / Sneaker-Monitors

A collection of web monitors that notify of restocks or updates on sneaker related sites through Discord Webhook. This includes Shopify, Nike SNKRS (supports 42 countries), Supreme and now Footsite monitors!
GNU General Public License v3.0
462 stars 126 forks source link

Error trying to start monitor #97

Closed plnd1 closed 3 years ago

plnd1 commented 3 years ago

As soon as I start the monitor, the payload is successfully delivered to my Discord, then, when it tries to connec to Nike, this error shows up:

File "C:\Users\Pichau\Desktop\Sneaker-Monitors-master\SNKRS\SNKRSMonitor.py", line 236, in <module>
    monitor()
  File "C:\Users\Pichau\Desktop\Sneaker-Monitors-master\SNKRS\SNKRSMonitor.py", line 187, in monitor
    items = scrape_site(proxy, headers)
  File "C:\Users\Pichau\Desktop\Sneaker-Monitors-master\SNKRS\SNKRSMonitor.py", line 39, in scrape_site
    output = json.loads(html.text)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\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)

PS: Using in Brazilian Snkrs

EdgarRMed commented 3 years ago

I´ve just found that it´s happening due to the 403 forbidden response of the API, have you find any solution?

yasserqureshi1 commented 3 years ago

This problem can be solved if you add the following code between lines 37 and 38:

headers = {"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Mobile Safari/537.36"}