我正在嘗試使用此代碼在此網站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"}))
但我得到的結果是None而不是網站中現有事實的串列!關于我的代碼有什么問題的任何想法
uj5u.com熱心網友回復:
您可以使用 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://www.uj5u.com/gongcheng/480107.html
