-1
ウェブサイト上で検索クエリを使用してCVEやCommon Vulnerabilities and Exposuresを検索し、その結果の表を印刷要求で印刷する必要があります。私は結果をこするために使用しているウェブサイトは、コードへの私のpython 3を使用していhttps://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=CVE+2017AttributeError: 'NoneType'オブジェクトに 'find'属性がありません
あり、それに新しいですし、プロジェクト
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)
としてこれを使用していた私に、次のエラーが発生します:
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'
'soup.find( 'TBODY'、ID = 'TableWithRules')' 'NONE'、テーブル= NONE''ので、あなたは、TR '( 'table.findを行っている返します') 'と' None.find() 'は未定義です。 – Adirio
id(TableWithRules)はdivタグに関連付けられており、tbodyと書かれています –
また、すべての行とすべての列を取得するためにはfind_allを使用しなければなりません.find()したがって、結果セットを返しません –