I have to search for CVE's or Common Vulnerabilities and Exposures through a search query on a website and then print the import the resulting table in my print request. The website I'm using for scraping of the results are https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=CVE+2017
I'm using python 3 to code and am new to it and wanted to use this as a project
import urllib.request
import urllib
searchStr = input("Enter Search Query \n")
r = urllib.request.urlopen("https://cve.mitre.org/cgi-bin/cvekey.cgi?
keyword="+searchStr)
source_code = r.read()
from bs4 import BeautifulSoup
soup = BeautifulSoup(source_code, 'html.parser')
table = soup.find('tbody', id = 'TableWithRules')
rows = table.find('tr')
for tr in rows:
cols = tr.find('td')
p = cols[0].text.strip()
d = cols[1].text.strip
print(p)
print(d)
Gives me the following error:
Traceback (most recent call last):
File "C:\Users\Devanshu Misra\Desktop\Python\CVE_Search.py", line 9, in
<module>
rows = table.find('tr')
AttributeError: 'NoneType' object has no attribute 'find'