获取免费代理IP
作者:互联网
import requests
from lxml import etree
url = ‘https://www.kuaidaili.com/free/inha/{}/’
headers = {‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:70.0) Gecko/20100101 Firefox/70.0’}
response = requests.get(url.format(1),headers=headers).text
text = etree.HTML(response)
ips = text.xpath(’//[@id=“list”]/table/tbody/tr/td[1]/text()’)
ports = text.xpath(’//[@id=“list”]/table/tbody/tr/td[2]/text()’)
print(ips,ports)
results =zip(ips,ports)
for i in results:
ip = ‘{}:{}’.format(i[0],i[1])
print(ip)
标签:headers,IP,format,代理,results,ips,text,免费,ports 来源: https://blog.csdn.net/weixin_39888502/article/details/121621184