如何识别IP地址的用户类型?使用 python 和 requests/bs4/flask

How do I identify the user type of an IP address? Using python and requests/bs4/flask

我将 python 与 requests/bs4/flask 一起使用,我想确定传入 IP 请求到我的烧瓶应用程序的用户类型。

http://ipleak.net 将类型标识为住宅、大学、咖啡馆、公司等,但他们只检查您的 IP。

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

如何在不使用 API 的情况下识别 IP 类型?我可以少 accuracy/classification。这个有 public API 吗?或者我可以从 whois 数据库中抓取它吗?或者我可以用其他方式识别它吗?

我监控了网络流量,发现了检查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