如何使用Beautiful Soup查找带有特定文本的href链接?

时间:2018-10-27 15:56:07

标签: python

page = urllib2.urlopen('https://www.sec.gov/Archives/edgar/data/1591890/0001493152-18-003887-index.htm').read()
soup = BeautifulSoup(page)
soup.prettify()
# page = requests.get('https://www.sec.gov/Archives/edgar/data/1591890/0001493152-18-003887-index.htm')

# soup = BeautifulSoup(page, 'html.parser')
# Remove bottom links


for link in soup.findAll('a', href=True,text = re.compile('instance')):
    print link['href']

运行此程序没有任何链接。

1 个答案:

答案 0 :(得分:0)

您可以简单地修改汤调用以获取findAll()返回的字典的“ href”键。这应该可以满足您的需求:

using UnityEngine;
using UnityEngine.UI;