from BeautifulSoup import BeautifulSoupimport rehtml_text = """<h2>this is cool #12345678901</h2><h2>this is nothing</h2><h1>foo #126666678901</h1><h2>this is interesting #126666678901</h2><h2>this is blah #124445678901</h2>"""soup = BeautifulSoup(html_text)for elem in soup(text=re.compile(r' #S{11}')): print elem.parent
印刷品:
<h2>this is cool #12345678901</h2><h2>this is interesting #126666678901</h2><h2>this is blah #124445678901</h2>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)