2016-06-06 36 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 
相關問題