Max Retries Exceeded with Url in Requests

Max retries exceeded with url in Requests Python

Add headers.

Disguise the browser.

import requests

headers = {
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'}

url_1 = 'http://www.dsit.org.ir/?cmd=page&Cid=92&title=Kontakt&lang=fa'

print(requests.get(url=url_1, headers=headers).text)

Python API call using requests throws Max retries exceeded with url error

requests expects a certificate with the PEM format your .pfx file is in the PKCS#12 format.

You can either change your certificate format : Converting pfx to pem using openssl.

Or you can use this library that adds PKCS#12 support to requests.

Max retries exceeded with url and certificate verify failed while using Python requests

You are getting the error because the site's certificate is expired. You can modify the code as below to bypass verification.

Also make a note that you shouldn't do this with untrusted sites.

import requests

my_lat = 51.507

my_long = -0.1277

parameters = {"lat": my_lat, "lng": my_long}

response = requests.get(
"https://api.sunrise-sunset.org/json", params=parameters, verify=False
)
response.raise_for_status()

data = response.json()

print(data)


Related Topics



Leave a reply



Submit