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
463 stars 125 forks source link

SNKRS monitor Crashing #101

Closed param-veer closed 3 years ago

param-veer commented 3 years ago

When you try to run the SNKRS monitor with any IN (India) Country code or even the default GB settings. It crashes after it tries to load the json from the SNKRS LINK.

I am using python-3.9.0 and all the latest versions of the requirements.

I had run this on server once and here are the error logs

2021-06-29T00:26:04.045858+00:00 app[worker.1]: File "/app/SNKRSMonitor.py", line 237, in 2021-06-29T00:26:04.046119+00:00 app[worker.1]: monitor() 2021-06-29T00:26:04.046121+00:00 app[worker.1]: File "/app/SNKRSMonitor.py", line 188, in monitor 2021-06-29T00:26:04.046327+00:00 app[worker.1]: items = scrape_site(proxy, headers) 2021-06-29T00:26:04.046356+00:00 app[worker.1]: File "/app/SNKRSMonitor.py", line 39, in scrape_site 2021-06-29T00:26:04.046534+00:00 app[worker.1]: output = json.loads(html.text) 2021-06-29T00:26:04.046560+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/json/init.py", line 346, in loads 2021-06-29T00:26:04.046918+00:00 app[worker.1]: return _default_decoder.decode(s) 2021-06-29T00:26:04.046943+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 337, in decode 2021-06-29T00:26:04.047241+00:00 app[worker.1]: obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 2021-06-29T00:26:04.047267+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/json/decoder.py", line 355, in raw_decode 2021-06-29T00:26:04.047562+00:00 app[worker.1]: raise JSONDecodeError("Expecting value", s, err.value) from None 2021-06-29T00:26:04.047623+00:00 app[worker.1]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2021-06-29T00:26:04.233826+00:00 heroku[worker.1]: Process exited with status 1 2021-06-29T00:26:04.303882+00:00 heroku[worker.1]: State changed from up to crashed

cealsan commented 3 years ago

STARTING MONITOR Payload delivered successfully, code 204. Traceback (most recent call last): File "SNKRSMonitor.py", line 236, in monitor() File "SNKRSMonitor.py", line 187, in monitor items = scrape_site(proxy, headers) File "SNKRSMonitor.py", line 39, in scrape_site output = json.loads(html.text) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/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)

agocharbhatia commented 3 years ago

STARTING MONITOR Payload delivered successfully, code 204. Traceback (most recent call last): File "SNKRSMonitor.py", line 236, in monitor() File "SNKRSMonitor.py", line 187, in monitor items = scrape_site(proxy, headers) File "SNKRSMonitor.py", line 39, in scrape_site output = json.loads(html.text) File "/usr/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/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)

yasserqureshi1 commented 3 years ago

It works if you put the following code in between lines 36 and 37:

headers = { "user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"}
ToliaGuy commented 3 years ago

It works if you put the following code in between lines 36 and 37:

headers = { "user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"}

There is a bug in the line 187. Author of the code just simply interchanged proxy and headers arguments: line 28: def scrape_site(headers, proxy): - here function expect headers to be parsed and second is expected to be a proxy line 187: items = scrape_site(proxy, headers) - but here you are parsing proxy first and headers as a second argument. So basically just change the line 187: items = scrape_site(headers, proxy)