我正在编写一个刮刀来从网站上获取CVE的详细信息 . 因为我没有看到任何错误,所以我不确定我哪里出错了 . 它也没有显示结果 .
这是我写的代码 . 结果应该是CSV中的这些细节 .
from urllib.request import urlopen
from bs4 import BeautifulSoup
import csv
file = "Details.csv"
Headers = ("CVE ID", "CWE ID", "# of Exploits", "Vulnerability Type(s)",
"Publish Date", "Update Date", "Score", "Gained Access Level", "Access",
"Complexity", "Authentication", "Confidentiality", "Integrity",
"Availability")
f = open(file, "w")
csvriter = csv.writer(f, delimiter=',', quotechar='"')
csvriter.writerow(Headers)
for page in range(1,130):
url = "https://www.cvedetails.com/vulnerability-list.php?
vendor_id=0&product_id=0&version_id=0&page={}&hasexp=0&opdos=0&opec=0&opov=0&opcsrf=0&opgpriv=0&opsqli=0&opxss=0&opdirt=0&opmemc=0&ophttprs=0&opbyp=0&opfileinc=0&opginf=0&cvssscoremin=0&cvssscoremax=0&year=2015&month=0&cweid=0&order=1&trc=6484&sha=f941b721732be362e81064704448767014116e7c".format(page)
html = urlopen(url)
soup = BeautifulSoup(html,"html.parser")
Title = soup.find_all("div", {"class":"searchresults sortable"})
for i in Title:
try:
name = i.find("div", {"class":"srrowns"}).get_text()
print("name", file = f)
#f.write("{}".format(name).replace(",",",",",",",",",","|")+ "\n")
except: AttributeError
f.close()