def test_isalive(self):
     # 检测代理IP的有效性
     obj = getProxys("proxy.db")
     flage = obj.isAlive("22.18.42.2", "90")
     self.assertEqual(flage, True)
 def test_getip(self):
     # 提取数据库里面的代理ip数据,num代表获取代理ip个数 test_urls满足目标网址测试列表
     obj = getProxys("proxy.db")
     ip, port, Proxies = obj.getProxyIP(num=10,
                                        test_urls=["http://www.baidu.com"])
     self.assertEqual(len(Proxies), 10)
 def test_addapi(self):
     # 添加解析接口(内置一个解析api)
     obj = getProxys("proxy.db")
     obj.load_func("http://www.xicidaili.com/nn/", spider_proxy_0)
     obj.load_func("https://www.free-proxy-list.net/", spider_proxy_2)
 def test_updatedb(self):
     # 获取数据更新数据库并检测数据库里面的代理ip
     obj = getProxys("proxy.db")
     obj.update_db()
 def test_init(self):
     # 数据库是本地保存路径
     getProxys("proxy.db")