import parsel import requests url = '' headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', } html = requests.get(url=url, headers=headers).text html = parsel.Selector(html) Ip = html.xpath('//td[@data-title="IP"]/text()').extract() Port = html.xpath('//td[@data-title="PORT"]/text()').extract() LeiXing = html.xpath('//td[@data-title="类型"]/text()').extract() result = [] for i in range(len(Ip)): a = (LeiXing[i] + '://' + Ip[i] + ':' + Port[i]) pro = {LeiXing[i]: a} result.append(pro) for i in result: try: ssss = requests.get(url='http://www.baidu.com', headers=headers, proxies=i, timeout=1).status_code if ssss == 200: print(i) except: print('不合格')
评论 (0)