Python 抓取 Microsoft CVE 网页时出错

Python Error while Scraping Microsoft CVE Webpage

所以,我阅读了下面的问题。答案提供了一些代码供进一步测试。

看起来像

https://portal.msrc.microsoft.com/api/security-guidance/en-US/CVE/CVE-2018-8176

不工作。它返回默认 HTML 页面而不是实际内容。它一直工作到上个月。并返回 JSON 数据 有人可以帮我找到新的 URL 可以 returns 适当的 json 数据。

谢谢

您可以使用此示例下载带有 CVE 数据的 Json:

import json
import requests
from bs4 import BeautifulSoup

url = (
    "https://api.msrc.microsoft.com/sug/v2.0/en-US/vulnerability/CVE-2018-8176"
)

data = requests.get(url).json()

# uncomment to print all data:
# print(json.dumps(data, indent=4))

print(data["cveTitle"])
print(BeautifulSoup(data["description"], "html.parser").get_text(strip=True))

打印:

Microsoft PowerPoint Remote Code Execution Vulnerability
A remote code execution vulnerability exists in Microsoft PowerPoint software when the software fails to properly validate XML content. An attacker who successfully exploited the vulnerability could run arbitrary code in the context of the current user. If the current user is logged on with administrative user rights, an attacker could take control of the affected system. An attacker could then install programs; view, change, or delete data; or create new accounts with full user rights. Users whose accounts are configured to have fewer user rights on the system could be less impacted than users who operate with administrative user rights.Exploitation of the vulnerability requires that a user open a specially crafted file with an affected version of Microsoft Office PowerPoint software. In an email attack scenario, an attacker could exploit the vulnerability by sending the specially crafted file to the user and convincing the user to open the file. In a web-based attack scenario, an attacker could host a website (or leverage a compromised website that accepts or hosts user-provided content) that contains a specially crafted file designed to exploit the vulnerability. An attacker would have no way to force users to visit the website. Instead, an attacker would have to convince users to click a link, typically by way of an enticement in an email or instant message, and then convince them to open the specially crafted file. After the file is open, the user would need to move their mouse over a specific location on the page within the PowerPoint file to trigger the vulnerability.Note that the Preview Pane is not an attack vector for this vulnerability. The security update addresses the vulnerability by correcting how Microsoft PowerPoint handles objects in memory.