【问题标题】:how to get the context following a Keyword search in BeautifulSoup?如何在 BeautifulSoup 中进行关键字搜索后获取上下文?
【发布时间】:2015-06-10 21:29:14
【问题描述】:

我正在尝试获取“责任”之后的上下文。但我无法完成它。如何获取没有标签的上下文?

<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>

【问题讨论】:

  • 您的意思是要从&lt;ul&gt; 中获取&lt;strong&gt; 标记之后的文本?

标签: python html beautifulsoup


【解决方案1】:

以下应该可以工作:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-30
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 1970-01-01
    • 2011-07-10
    • 1970-01-01
    • 2013-08-03
    相关资源
    最近更新 更多