[
这样的事情行吗?
In [39]: from bs4 import BeautifulSoupIn [40]: s = """ ....: <a href="http://example.com">TEXT</a> ....: <a href="http://example.com/link">TEXT</a> ....: <a href="http://example.com/page">TEXT</a> ....: <a href="http://dontmatchme.com/page">WRONGTEXT</a>"""In [41]: soup = BeautifulSoup(s)In [42]: for link in soup.findAll('a', href=True, text='TEXT'): ....: print link['href'] ....: ....:http://example.comhttp://example.com/linkhttp://example.com/page
](file:///C:/Users/Jiang/Desktop/spider/pages/python/page_750_08.html)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)