Home > Back-end >  Need the link and the text from the website
Need the link and the text from the website

Time:06-10

I just get ouput as below however looking for CVE-2022-1285

CVE-2022-1285 None

url ='https://nvd.nist.gov/vuln/full-listing/2022/6'
response = requests.get(url)
soup = bs(response.text,'html.parser')
for cve in soup.find_all('span',class_='col-md-2'):
        print(cve.text, cve.get('href'))

CodePudding user response:

Instead of trying to extract the link from the span element, you can grab the a tag` and use the same method. For example:

url ='https://nvd.nist.gov/vuln/full-listing/2022/6'
response = requests.get(url)
soup = bs(response.text,'html.parser')
for cve in soup.find_all('span',class_='col-md-2'):
        print(cve.text, cve.a.get('href'))
        # link =  cve.a.get('href')
        # print(link)
  • Related