打印可能包含列表

时间:2017-08-12 06:42:39

标签: python beautifulsoup

如何从包含单词列表中的单词的网页打印所有链接。我得到了包含“联系人”字样的链接列表。使用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;

0 个答案:

没有答案
相关问题