crawl_xici_ip.py 文件源码

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

项目:ArticleSpider 作者: mtianyan 项目源码 文件源码
def judge_ip(self, ip, port):
        #??ip????
        http_url = "http://www.baidu.com"
        proxy_url = "http://{0}:{1}".format(ip, port)
        try:
            proxy_dict = {
                "http":proxy_url,
            }
            response = requests.get(http_url, proxies=proxy_dict)
        except Exception as e:
            print ("invalid ip and port")
            self.delete_ip(ip)
            return False
        else:
            code = response.status_code
            if code >= 200 and code < 300:
                print ("effective ip")
                return True
            else:
                print  ("invalid ip and port")
                self.delete_ip(ip)
                return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号