proxy_handler.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:Utils 作者: disconsis 项目源码 文件源码
def find_free_proxies(url='http://icanhazip.com/'):
    def _free_proxies_thread_worker(proxy, url, _list):
        if test_proxy(proxy, url) is True:
            _list.append(proxy)

    logger = logging.getLogger(__name__)
    free_proxies = []
    main_thread = threading.currentThread()
    for proxy in proxy_list:
        threading.Thread(target=_free_proxies_thread_worker,
                         args=(proxy, url, free_proxies)).start()
    for thread in threading.enumerate():
        if thread is not main_thread:
            thread.join()
    if not len(free_proxies):
        logger.critical('no working proxies')
        return None
    return free_proxies
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号