ok_ip_proxy_pool icon indicating copy to clipboard operation
ok_ip_proxy_pool copied to clipboard

如何实现随机代理

Open U188 opened this issue 4 years ago • 1 comments

get一个代理时 可以实现在池中随机获取一个代理的功能吗

U188 avatar Feb 08 '21 15:02 U188

import requests #本地端口ip地址获取 PROXY_POOL_URL = 'http://localhost:8080/random'

def get_proxy(): try: #访问程序提供的ip地址获取链接 response = requests.get(PROXY_POOL_URL) #如果获取成功,返回获取的ip地址 if response.status_code == 200: return response.text except ConnectionError: return None

lvwuwei avatar Mar 23 '21 20:03 lvwuwei