IP信誉信息查询

从ipip.net网站上查询ip的信誉信息,如基站、IDC等
查询地址:https://www.ipip.net/ip.html

代码:

import requests
from lxml import etree
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

requests.packages.urllib3.disable_warnings()#忽略警告
check_ip="61.148.244.109"
url="https://www.ipip.net/ip.html"

page_headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0',
        'Connection': 'keep-alive',
        'Content-Type':'application/x-www-form-urlencoded',
        'Referer':'https://www.ipip.net/ip.html',
        'Host':'www.ipip.net',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Cookie':'__jsluid=937f34ce3db5c1da1e1e85461b022399; LOVEAPP_SESSID=853504cea180e7a9aee339a505e0547cf8a6f1e6; _ga=GA1.2.1286347564.1530842494; _gid=GA1.2.734570262.1531041332'
    }

def url_open(check_ip):
    post_data={'ip':check_ip}
    res=requests.post(url,headers=page_headers,data=post_data,verify=True)
    status=res.status_code
    content=res.text
    #print(status)
    return status,content

def check_ipip(check_ip):
    status,content=url_open(check_ip)
    if status==200:
        html=etree.HTML(content)
        ip_creditL=html.xpath('//div[@class="outer tableNormal ipSearch"]//div[@class="inner"]//table[1]//tr[5]//td[1]//text()')
        if len(ip_creditL)>0:
            ip_credit=ip_creditL[0]
        else:
            ip_credit=" "
        print(ip_credit)  

check_ipip(check_ip) 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jepson2017

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值