获取免费代理IP

2021/11/29 23:09:06

本文主要是介绍获取免费代理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)



这篇关于获取免费代理IP的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程