requests.get("http://192.168.5.29:5010/get/").json()始终为空
- Dominant language
- Python
- Stars
- 23.7k
- Forks
- 5.4k
- PR merge metrics
- No merged PRs in 30d
Description
import requests
def get_proxy():
#5000:settings中设置的监听端口,不是Redis服务的端口
return requests.get("http://192.168.5.29:5010/get/").json()
def delete_proxy(proxy):
requests.get("http://192.168.5.29:5010/delete/?proxy={}".format(proxy))
# 主代码
def getHtml():
retry_count = 5
proxy = get_proxy().get('proxy')
print(proxy)
while retry_count > 0:
try:
html = requests.get('http://www.baidu.com', proxies={"http": "http://{}".format(proxy)})
print(html.text)
break
except Exception:
retry_count -= 1
# 删除代理池中代理
delete_proxy(proxy)
return None
getHtml()
print(proxy)始终为空
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.