Home > other >  extract information from website using python
extract information from website using python

Time:05-23

I'm trying to get the iformations about the indicator facts in this website https://otx.alienvault.com/indicator/ip/13.107.21.200 using this code

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"}))

but i got None as result instead of a list of existing facts in the website ! any idea about what is wrong on my code

CodePudding user response:

You can get the necessary information from the site using the 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')
  • Related