代理服务器

l = [
     '106.39.179.236:80',
    '23.94.191.219:1080',
    '121.41.175.199:80',
    '122.183.139.98:8080',
    '118.193.107.182:80',
    '92.42.109.45:1080',
    '128.199.77.93:8080',
    '46.101.60.239:8118',
    '185.106.121.98:1080',
    '185.82.203.81:1080',
    '112.114.93.27:8118',
    '104.131.69.203:80',
    '138.201.0.184:1080',
    '46.101.46.174:8118',
    '178.62.123.38:8118',
    '217.23.15.193:1080',
    '60.168.207.208:8010',
    '139.59.170.110:8118',
    '223.241.118.228:8010',
    '123.192.114.113:80',
    '103.37.95.110:8000',
    '180.179.43.250:80',
    '185.117.74.81:1080',
    '116.199.2.196:80',
    '118.193.107.119:80',
    '128.199.77.93:8000',
    '170.246.114.213:8080',
    '104.243.47.146:1080',
    '111.3.108.44:8118',
    '124.42.7.103:80',
    '39.134.161.18:80',
    '146.185.156.221:8118',
    '47.89.249.110:80',
    '118.193.107.192:80',
    '124.232.163.10:3128',
    '223.19.105.206:80',
    '46.166.168.243:1080',
    '118.114.77.47:8080',
    '182.253.205.85:8090',
    '45.55.132.29:9999',
    '58.251.227.238:8118',
    '118.193.107.142:80',
    '118.193.107.135:80',
    '118.193.107.219:80',
    '46.101.45.212:8118',
    '114.249.45.176:8118',
    '80.152.201.116:8080',
    '94.177.254.86:80',
    '197.155.158.22:80',
    '196.200.173.83:80',
    '212.237.10.45:8080',
    '188.166.144.173:8118',
    '210.71.198.230:8118',
    '177.114.228.112:8080',
    '218.50.2.102:8080',
    '198.204.251.158:1080',
    '188.166.204.221:8118',
    '185.117.74.126:1080',
    '106.39.179.244:80',
    '39.134.161.14:8080',
    '85.10.247.136:1080',
    '46.166.168.245:1080',
    '5.167.50.35:3129',
    '118.178.227.171:80',
    '122.96.59.102:82',
    '52.174.89.111:80',
    '103.25.173.237:808',
    '121.232.145.168:9000',
    '103.251.167.8:1080',
    '46.101.26.217:8118',
    '171.37.178.175:9797',
    '103.251.166.18:1080',
    '186.225.176.93:8080',
    '121.232.147.132:9000',
    '104.224.168.178:8888',
    '47.90.2.253:8118',
    '121.232.145.82:9000',
    '118.193.107.36:80',
    '58.56.128.84:9001',
    '139.59.153.59:80',
    '122.183.139.101:8080',
    '163.172.184.226:8118',
    '198.204.251.146:1080',
    '213.133.100.195:1080',
    '42.104.84.106:8080',
    '117.2.64.109:8888',
    '121.232.144.229:9000',
    '156.67.219.61:8080',
    '138.36.106.90:80',
    '1.179.233.66:80',
    '222.33.192.238:8118',
    '138.197.224.12:8118',
    '151.106.10.6:1080',
    '134.35.250.204:8080',
    '58.251.227.233:8118',
    '52.221.40.19:80',
    '222.73.68.144:8090',
    '46.166.168.247:1080',
    '192.99.222.207:80',
    '1.23.160.212:8080',
 ]
#394996257  aljnn6er
#116.62.112.142  16816

from urllib import request
import re

# 检测代理服务器
def checkProxy(html):
    data = re.compile("<title>百度一下,你就知道</title>")
    title = data.findall(html)
    if title:
        return True
    return False


def user_http_proxy(proxy_addr, url):
    # 构造代理服务器handler
    proxyH = request.ProxyHandler({"http":proxy_addr})
    # 由这个proxy handler创建一个http的opener
    opener = request.build_opener(proxyH, request.HTTPHandler)
    # 把这个opener装进urllib
    request.install_opener(opener)
    
    # 请求
    res = request.urlopen(url, timeout=6)
    # 读取信息
    data = res.read().decode()
    return data


if __name__ == "__main__":
#    proxy_addr = "394996257:aljnn6er@116.62.112.142:16816"

#    测试免费代理服务器
#    for i in l:
#        proxy_addr = i
#        try:
#            data = user_http_proxy(proxy_addr, "http://www.sina.com")
#            print(i)
#        except:
#            continue
        
#121.41.175.199:80
#124.42.7.103:80
#197.155.158.22:80
#218.50.2.102:8080
#58.56.128.84:9001
    
    
    proxy_addr = "124.42.7.103:80"
    data = user_http_proxy(proxy_addr, "http://www.baidu.com")
    print(checkProxy(data))
    with open('1.html','wb') as f:
        f.write(data.encode())
        
    
#    print(data)
 

!DOCTYPE html> <html 85.3333px;"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta http-equiv="Cache-Control" content="no-transform"> <meta name="applicable-device" content="mobile"> <meta http-equiv="Cache-Control" content="no-siteapp"> <title>【元旦倒计时】2020新年倒计时_距离2020年还有多少天</title> <style> .timebox2{width:640px;background-color:#FCF3E2;padding: 1rem 0;background: url(images/ks_bcg2.png) center center no-repeat;background-size: 100% 100%;} .timebox2 div,timebox2 span,timebox2 div span{color: #333 !important;} .timebox2 .timecounter span{color: #333 !important;} .timetext{width: 100%;text-align: center;} .timetexttitle{font-size:0.3rem;margin-bottom: 10px;color: #fff;} .timetextintro{font-size: 0.22rem;margin-bottom: 10px;color: #fff;padding: 0 1.52rem;box-sizing: border-box;} .timecounter{font-size: 0.6rem;} .txt{padding: 0 0.2rem;box-sizing:border-box;} .clearbg5{display: block;clear: both;width: 100%;height: 0.16rem;overflow: hidden;background-color: #eee;} .txt p{line-height: 30px;margin-top: 0.2rem;} .txt p img{width: 100%;} .timecounter span{color: #fff;} </style> <body> 2020年元旦倒计时 元旦时间:2020年1月1日 农历腊月初七 星期三 目前距离2020年元旦还有 127 天 10 时 24 分 8 秒 [removed] function getRTime() { var EndTime = new Date("2020/01/01 00:00:00"); //截止时间 var NowTime = new Date(); var t = EndTime.getTime() - NowTime.getTime(); var d = Math.floor(t / 1000 / 60 / 60 / 24); var h = Math.floor(t / 1000 / 60 / 60 % 24); var m = Math.floor(t / 1000 / 60 % 60); var s = Math.floor(t / 1000 % 60); document.getElementById("t_d")[removed] = d + " 天"; document.getElementById("t_h")[removed] = h + " 时"; document.getElementById("t_m")[removed] = m + " 分"; document.getElementById("t_s")[removed] = s + " 秒"; } setInterval(getRTime, 1000); [removed] </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值