Answer the question
In order to leave comments, you need to log in
How to implement random proxy selection before each request?
I have an api request code
def get_weathermap(self):
try:
rq=requests.get(f'api.openweathermap.org/data/2.5/weather?lat=35&lon=139')
self.is_200(rq)
res=rq.json()#json.loads(rq.text)
self.is_success_api(res)
except:
print('EXCEPTION: get_weathermap >',sys.exc_info())
def get_weathermap(self):
try:
http_proxy = "http://108.61.209.46:3128"
https_proxy = "https://108.61.209.46:3128"
ftp_proxy = "ftp://108.61.209.46:3128"
proxyDict = {
"http": http_proxy,
"https": https_proxy,
"ftp": ftp_proxy
}
rq=requests.get(f'api.openweathermap.org/data/2.5/weather?lat=35&lon=139', proxies = proxyDict)
self.is_200(rq)
res=rq.json()#json.loads(rq.text)
self.is_success_api(res)
except:
print('EXCEPTION: get_weathermap >',sys.exc_info())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question