【发布时间】:2022-01-25 14:32:33
【问题描述】:
我如何使用 Python 代码判断特定 IP (ipv4) 是否属于亚马逊、阿里巴巴或 AWS?
以 AWS 为例,如果 IP 有数百万。
我没有找到任何简单的方法来做到这一点。
【问题讨论】:
-
尝试反向 dns 查找。
标签: python python-3.x ip amazon ipv4
我如何使用 Python 代码判断特定 IP (ipv4) 是否属于亚马逊、阿里巴巴或 AWS?
以 AWS 为例,如果 IP 有数百万。
我没有找到任何简单的方法来做到这一点。
【问题讨论】:
标签: python python-3.x ip amazon ipv4
这是我所知道的最简单的方法:
from bs4 import BeautifulSoup
import requests
def check(ip):
get_ip_info = requests.post(f'https://who.is/whois-ip/ip-address/{ip}').content
soup = BeautifulSoup(get_ip_info, 'html.parser')
result = soup.findAll('pre')
print(result)
check("IP address what you want to check as string")
您将获得一个对象,其中将包含有关组织名称的数据,如屏幕截图所示:
【讨论】: