其他分享
首页 > 其他分享> > 高质量代理ip+ssl证书解决

高质量代理ip+ssl证书解决

作者:互联网

import requests
from pprint import *

# 解决https证书爆红
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


# url0 = "https://ip.jiangxianli.com/?page=1"
url1 = " https://ip.jiangxianli.com/api/proxy_ips/"
header = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
}
ip_list = []


def getIP():
    res = requests.get(url1,headers=header,verify=False)
    text = res.json()
    data_list = text['data']['data']
    pprint(len(data_list))

    # 代理格式:{"ip的协议" : "ip: ip的端口"}

    for i in data_list:
        proxies_dict = {}
        ip = i["ip"]
        port = i['port']
        protocol = i['protocol']
        proxies_dict[protocol] = ip + ':' + port
        ip_list.append(proxies_dict)
        # print(ip)


def checkIP(data):
    good_ip = []
    for ip in data:
        try:
            check = requests.get("https://www.bilibili.com/video/BV1wz411i735", headers=header,proxies=ip,timeout=5)
            # print(check.status_code)
            if check.status_code == 200:
                good_ip.append(ip)
        except Exception as e :
            print("质量不行的ip")
    return good_ip

getIP()
canuip = checkIP(ip_list)
print(len(canuip))
pprint(canuip)

 

标签:高质量,ip,list,ssl,https,print,proxies,data
来源: https://www.cnblogs.com/zwnsyw/p/14411456.html