我想使用10个代理的字典中的随机代理来发送获取请求。代理是真实的,我正在使用集成身份验证。
我将使用代码:
prox = {"https" : "https://user:pass@xxx.xxx.xxx.xxx:xxxx", "https" :
"https://user:pass@xxx.xxx.xxx.xxx:xxxx", "https":
"https://user:pass@xxx.xxx.xxx.xxx:xxxx"}
k = prox.keys()[random.randint(0,len(prox))]
NewArrUrl = 'https://www.xxxxxxxxx.com/en/xx/secxn/xxxxxxxx'
responseNewArr = requests.get(url = NewArrUrl, verify = False, headers = headersNewArr, allow_redirects = False, proxies = ??????? )
我尝试过random.choice(list(prox.items()))
,但是它抛出了:
no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'tuple' object has no attribute 'get'.
我不明白为什么需要定义'if proxy == None'