Python 在HTML中打印标题后的“p”标记的内容

Python 在HTML中打印标题后的“p”标记的内容,python,html,scraper,Python,Html,Scraper,我正试图完成一项数据清理任务。除了最后一部分,我需要打印根据用户搜索标准向网站报告的网络安全漏洞的描述 for index in range(2): response = requests.get(url_values[index]) content = response.content soup = BeautifulSoup(content,"lxml") #find the table content for header in soup.find

我正试图完成一项数据清理任务。除了最后一部分,我需要打印根据用户搜索标准向网站报告的网络安全漏洞的描述

for index in range(2): 
    response = requests.get(url_values[index])
    content = response.content
    soup = BeautifulSoup(content,"lxml")
    #find the table content
    for header in soup.find_all("h3", string = "Description"):
        text = find_next.("p")
        print (text)
这就是我试图从中获取信息的区域中HTML的外观:

 ...<section class="content-band">              
        <div class="content">



            <h3>Risk</h3>                           

            <div><p>Low</p></div>






            <h3>Date Discovered</h3>
            <p>February 12, 2019</p>




            <h3>Description</h3>
            <p>Microsoft Windows is prone to a local information-disclosure 
             vulnerability.                                                                        

            Local attackers can exploit this issue to obtain sensitive 
            information that may lead to further attacks.</p>




            <h3>Technologies Affected</h3>...
我想要描述头的p元素中的内容,它是h3元素。我也试着找到下一个兄弟姐妹,但似乎无法让它工作

任何建议都将不胜感激

您可以使用两个。在同一个soup对象上查找方法来查找h3元素,然后在该对象下查找p元素

text = soup.find("h3", string="Description").find("p").text

您不需要使用。全部查找,因为只有一个h3元素具有文本描述。

您可以从h3同级元素中获取文本,如下所示:

print(soup.find("h3", string="Description").find_next_sibling().text)

还请提供HTML的一个片段。