#爬取代理IP数据
import requests
from lxml import etree
# url = 'https://www.xicidaili.com/nn/'
url = 'http://ip.yqie.com/proxygaoni/'
headers = {
'User-Agent':'Mozilla / 5.0(Windows NT 10.0; WOW64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 72.0.3626.81 Safari / 537.36 SE 2.X MetaSr 1.0'
}
res = requests.get(url= url,headers =headers)
if res.status_code ==200 :
response = res.content.decode('utf-8')
res_html = etree.HTML(response)
ips = res_html.xpath('//table[@id="GridViewOrder"]//tr/td[2]/text()')
ports = res_html.xpath('//table[@id="GridViewOrder"]//tr/td[3]/text()')
data = list(zip(ips,ports))
for i in data:
print(i)
print(len(data))
08-18
1万+
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交