如何从包含单词列表中的单词的网页打印所有链接。我得到了包含“联系人”字样的链接列表。使用Beautifulsoup,代码如下所示。
soup = BeautifulSoup(html_page, "html.parser")
for link in soup.findAll('a'):
links = link.get('href')
if 'contact' in links:
print links
但是如何打印具有以下条件的链接
keywords = ("contact", "reach", "feedback", "address")
if links contain any words from keywords: ## this is not actual code
print links;