# _*_ coding:utf-8 _*_

import urllib2
import re class TestProxy(object):
def __init__(self, timeout):
self.url = 'http://www.baidu.com'
self.timeout = timeout
self.regex = re.compile(r'baidu.com') def TestIt(self, ip, port):
server = 'http://' + ip + ':' + port opener = urllib2.build_opener(urllib2.ProxyHandler({'http': server}))
urllib2.install_opener(opener)
try:
response = urllib2.urlopen(self.url, timeout=self.timeout)
except:
print '%s connect failed' % server
return False
else:
try:
str = response.read()
except:
print '%s connect failed' % server
return False
print str
if self.regex.search(str):
print '%s connect success .......' % server
print ip + ':' + port
return True if __name__ == '__main__':
proxylist = [("113.118.97.119", ""), ("221.222.245.208",""), ("61.155.164.110", "")] Tp = TestProxy(5)
for item in proxylist:
Tp.TestIt(item[0], item[1])

验证代理ip是否可用的更多相关文章

  1. python检验代理ip是否可用、代理ip检验

    python检验代理ip是否可用.代理ip检验 安装相关模块: pip install requests 验证代理IP是否可用脚本: import random import telnetlib im ...

  2. 【原创】验证代理IP是否有用

    /// <summary> /// 验证代理IP是否有用 /// </summary> /// <param name="ip">IP地址< ...

  3. python代理池的构建2——代理ip是否可用的处理和检查

    上一篇博客地址:python代理池的构建1--代理IP类的构建,以及配置文件.日志文件.requests请求头 一.代理ip是否可用的处理(httpbin_validator.py) #-*-codi ...

  4. Android中验证输入是否为汉字及手机号,邮箱验证,IP地址可用port号验证

    1,验证是否为汉字 // 验证昵称 private boolean verifyNickname() { String nickname = edt_username.getText().toStri ...

  5. Python 快速验证代理IP是否有效

    有时候,我们需要用到代理IP,比如在爬虫的时候,但是得到了IP之后,可能不知道怎么验证这些IP是不是有效的,这时候我们可以使用Python携带该IP来模拟访问某一个网站,如果多次未成功访问,则说明这个 ...

  6. 验证代理IP

    ##author:wuhao#import urllib.requestfrom http import cookiejar import xlrd import threading #有效的代理,可 ...

  7. Java 验证代理ip

    原文地址:http://www.cnblogs.com/junrong624/p/5416503.html 1 import java.io.IOException; import java.io.I ...

  8. c# 快速验证代理IP是否有用

    public void yanzhen(string str, int port) { WebProxy proxyObject = new WebProxy(str, port);//str为IP地 ...

  9. 如何验证代理ip的正确性

    python requests 使用代理的话: proxy_list = ["aabbcc.aabbcc.169.aabbcc:8080", ] ip_p = random.cho ...

随机推荐

  1. ionic3 双向数据绑定失效 脏值检测失效

    最近在使用ionic3过程中,使用了eval()方法进行字符串拼接成一个function使用 在eval()方法中,只能使用局部变量,全局变量无法使用,ionic3的this在eval中失效(unde ...

  2. PXE网络启动无人值守自动安装 centos 全程实录

    PXE网络启动无人值守自动安装 centos 全程实录 http://shayi1983.blog.51cto.com/4681835/1549854/ 搭建Pxe服务器无人听应答全自动安装CentO ...

  3. python和jupyter安装

    python官网:https://www.python.org/ 进去之后选择适合自己电脑的系统类型,安装,我的是windows  下载之后,双击打开 在安装时请勾选上add to path 选项,安 ...

  4. spark获取时间

    在spark 中获取时间用到java.util.{Calendar,Date} 以及java.text.SimpleDateFormat来对时间输出格式作规范 首先先导入包 import java.t ...

  5. html5(七) Web存储

    http://www.cnblogs.com/stoneniqiu/p/4206796.html http://www.cnblogs.com/v10258/p/3700486.html html5中 ...

  6. .Net Core2.1 部署到IIS

    1. 发布网站,和.net framework MVC一样 2.安装WindowsHosting和.Net Core SDK 下载地址:https://www.microsoft.com/net/do ...

  7. linux 使用split分割大文件

    1.分割 -- split命令 可以指定按行数分割和按字节大小分割两种模式. (1) 按行数分割 $ split -l 300 large_file.txt new_file_prefix 加上-d, ...

  8. Weka中数据挖掘与机器学习系列之Weka系统安装(四)

    能来看我这篇博客的朋友,想必大家都知道,Weka采用Java编写的,因此,具有Java“一次编译,到处运行”的特性.支持的操作系统有Windows x86.Windows x64.Mac OS X.L ...

  9. 微信开发】【Asp.net MVC】-- 微信分享功能

    [微信开发][Asp.net MVC]-- 微信分享功能 2017-01-15 09:09 by stoneniqiu, 12886 阅读, 15 评论, 收藏, 编辑 内嵌在微信中的网页,右上角都会 ...

  10. VSTO:使用C#开发Excel、Word【13】

    应用程序对象的操作本章将介绍从Application对象开始的Excel对象模型中的一些主要对象. Excel对象模型中的主要对象有许多方法和属性,完全描述这些对象超出了本书的范围.相反,本章重点介绍 ...