ok_ip_proxy_pool
ok_ip_proxy_pool copied to clipboard
如何实现随机代理
get一个代理时 可以实现在池中随机获取一个代理的功能吗
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