jeudi 25 avril 2019

WinError 10060 A connection attempt failed because the connected party did not properly respond after a period of time

My code is basically making a request to https://supremenewyork.com/shop/172346.json. Sometimes I get the error,

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='supremenewyork.com', port=443): Max retriesexceeded with url: /shop/172346.json (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] Aconnection attempt failed because the connected party did not properlyrespond after a period of time, or established connection failed because > connected host has failed to respond',)).

Important: This error only occurs sometimes. When it does happen, I have to wait for a while before my code to work.

I've already tried checking my proxy settings, and I know that is not the solution. I have also included headers shown in the code below.

headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'en-US,en;q=0.9',
    'cache-control': 'no-cache',
    'pragma': 'no-cache',
    'upgrade-insecure-requests': '1'}
link = ('This would be the url of the product')
productendpoint = requests.get(link, headers=headers)

(THIS ERROR ONLY HAPPENS SOMETIMES, NOT ALL THE TIME)

Most of the time, I get a response from the site, but sometimes I don't, and I need it to work all the time.




Aucun commentaire:

Enregistrer un commentaire