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

‘Connection aborted’ #99

Closed gmgm-gm closed 3 years ago

gmgm-gm commented 3 years ago

C:\Users\Owner\Desktop\Sneaker-Monitors-master\Sneaker-Monitors-master\SNKRS>python SNKRSMonitor.py

STARTING MONITOR

Payload delivered successfully, code 204.

('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))


After following all steps in the video and finally coming to the point of running the monitor, it gives out the error included above. I am trying to remake the SNKRSMonitor as shown on the video.

The SNKR bot on discord does send a message saying "this is just a quick test to ensure the webhook works. Thanks again for using these monitors!" With all of that being said, the monitors still do not work

yasserqureshi1 commented 3 years ago

There was an issue with the SNKRS monitor than can be fixed. See issue #97.

The connection aborted error can be caused when your computer is requesting the site multiple times at the same time. This is can be fixed by wrapping the code that requests the site in a try... except clause (i.e. lines 37 to 45). It should look something like this:

...
while anchor < 180:
   try:
      url = f'https://api.nike.com/product_feed/threads/v2/?anchor={anchor}&count=60&filter=marketplace%28{CONFIG["LOC"]}%29&filter=language%28{CONFIG["LAN"]}%29&filter=channelId%28010794e5-35fe-4e32-aaff-cd2c74f89d61%29&filter=exclusiveAccess%28true%2Cfalse%29&fields=active%2Cid%2ClastFetchTime%2CproductInfo%2CpublishedContent.nodes%2CpublishedContent.subType%2CpublishedContent.properties.coverCard%2CpublishedContent.properties.productCard%2CpublishedContent.properties.products%2CpublishedContent.properties.publish.collections%2CpublishedContent.properties.relatedThreads%2CpublishedContent.properties.seo%2CpublishedContent.properties.threadType%2CpublishedContent.properties.custom%2CpublishedContent.properties.title'
      html = rq.get(url=url, timeout=20, verify=False, headers=headers, proxies=proxy)
      output = json.loads(html.text)

      # Stores details in array
      for item in output['objects']:
          items.append(item)

      anchor += 60
    except Exception as e:
       print(e)

    logging.info(msg='Successfully scraped SNKRS site')
...