【问题标题】:How do I identify the user type of an IP address? Using python and requests/bs4/flask如何识别 IP 地址的用户类型?使用 python 和 requests/bs4/flask
【发布时间】:2016-06-06 17:13:27
【问题描述】:

我正在将 python 与 requests/bs4/flask 一起使用,并且我想识别对我的烧瓶应用程序的传入 IP 请求的用户类型。

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

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

如何在不使用 API 的情况下识别 IP 类型?我可以接受较少的准确性/分类。有这方面的公共 API 吗?或者我可以从 whois 数据库中抓取它吗?或者我可以用其他方式识别它吗?

【问题讨论】:

标签: python ip python-requests ip-address


【解决方案1】:

我监控了网络流量并找到了检查 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-15
    • 2021-10-06
    • 1970-01-01
    • 2014-11-07
    • 2021-01-03
    • 2011-04-15
    相关资源
    最近更新 更多