2016-06-06 37 views
0

我正在使用python请求/ bs4 /瓶,我想识别传入的IP请求的用户类型到我的烧瓶应用程序。如何识别IP地址的用户类型?使用python和请求/ bs4/flask

http://ipleak.net确定类型为住宅,学院,咖啡厅,企业等,但他们只检查您的知识产权。

GeoIP2是为此驱动ipleak.net的API,返回的参数称为用户类型。

如何在不使用API​​的情况下识别IP类型?我没有准确性/分类的好处。有这样的公共API吗?或者我可以从whois数据库中删除它?或者我能否以另一种方式识别它?

+0

有一个python的WHOIS LIB http://stackoverflow.com/questions/24580373/how-to-get-whois-info-by-ip-in-python-3/24586511#24586511 –

回答

0

我监控网络流量,发现呼叫来检查IP的类型。我写了这个函数来检查我传递给函数的任何IP。

import requests 
    from bs4 import BeautifulSoup 

    # check type of IP address 
    def ip_check(ip): 
     result = requests.get('https://ipleak.net/?mode=ajax&ip={}'.format(ip)) 
     soup = BeautifulSoup(result.text, 'html.parser') 
     parse = soup.get_text() 
     final = parse.replace('\xa0', '').replace(ip, '') 
     return final 
相关问题