#爬取代理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))
python 爬取代理IP网站
最新推荐文章于 2024-01-01 11:32:23 发布