Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 这是在web抓取中旋转代理的正确方法吗_Python_Python 3.x_Web Scraping - Fatal编程技术网

Python 这是在web抓取中旋转代理的正确方法吗

Python 这是在web抓取中旋转代理的正确方法吗,python,python-3.x,web-scraping,Python,Python 3.x,Web Scraping,我正在尝试在web抓取中从一组代理池中旋转代理。设置page\u response=“”是否正确 page_reponse = '' while page_reponse == '': proxy = next(proxy_pool) dict_proxy = {"http": proxy, "https": proxy} try: page_response = requests.get(iurl, headers=headers,timeout=tou

我正在尝试在web抓取中从一组代理池中旋转代理。设置
page\u response=“
”是否正确

page_reponse = ''
while page_reponse == '':
    proxy = next(proxy_pool)
    dict_proxy = {"http": proxy, "https": proxy}
    try:
        page_response = requests.get(iurl, headers=headers,timeout=tout, proxies=dict_proxy)
        break
    except requests.exceptions.ConnectionError as rec:
        pass
在不使用selenium的情况下,我应该如何在代码中实现以下语句:

try a proxy for 3 times and if still it gives error then only i should go to next proxy in the list