我试着用下面的代码来获取这个网站https://otx.alienvault.com/indicator/ip/13.107.21.200中关于指示性事实的信息
from bs4 import BeautifulSoup
from urllib.request import urlopen
theurl = "https://otx.alienvault.com/indicator/ip/13.107.21.200"
thepage = urlopen(theurl)
soup = BeautifulSoup(thepage,"html.parser")
print(soup.find('div',{"class":"item-container"}))但我得到了无作为结果,而不是一个现有的事实列表在网站上!知道我的代码出了什么问题吗?
发布于 2022-05-23 08:39:26
您可以使用API从站点获取必要的信息。
import requests
def get_facts(ip):
response = requests.get(f'https://otx.alienvault.com/otxapi/indicators/ip/analysis/{ip}')
print(response.json()['facts'])
get_facts('13.107.21.200')https://stackoverflow.com/questions/72345082
复制相似问题