from requests.exceptions import ConnectionError PROXY_POOL_URL = 'http://localhost:5000/get' def get_proxy(): try: response = requests.get(PROXY_POOL_URL) if response.status_code == 200: return response.text except ConnectionError: return None def get_html(): proxy = get_proxy() print(proxy) proxies = { 'http': 'http://' + proxy } try: response = requests.get('http://www.baidu.com', proxies=proxies) print(response.status_code) except: print('----') get_html()
利用代理池爬取
最新推荐文章于 2024-07-22 09:25:13 发布