如何获取BeautifulSoup中关键字搜索后的上下文?

时间:2015-06-10 21:29:15

标签: python html beautifulsoup

我正在努力获得"责任"之后的背景。但我无法完成它。如何在没有标签的情况下获取上下文?

<strong>RESPONSIBILITIES:</strong>

<ul>

<li>Reach or exceed assigned sales goals</li>

<li>Implement sales strategies</li>

<li>Develop and execute a cold calling strategy to target prospects</li>

<li>Mine existing and prospective clients for referral business</li>

<li>Establish and maintain strong relationships, with both internal partners and external customers</li>

</ul>

1 个答案:

答案 0 :(得分:0)

以下应该工作:

from bs4 import BeautifulSoup
import re
print soup.find('strong', text=re.compile('RESPONSIBILITIES:').find_next_sibling('ul').text