You could build a regular expression. I'm not sure about efficiency, you'd have to compare with @MosesKoledoye's nice answer.
To match against alternatives you use the pipe |
. You'd need something like legal|disclaimer|contact|faq|terms|log
as a pattern.
You can build that by joining a string '|'
with the values:
>>> values = {'legal', 'disclaimer', 'contact', 'faq', 'terms', 'log'}
>>> pattern = '|'.join(values)
>>> pattern
'terms|log|faq|legal|contact|disclaimer'
Using the re
(regular expression) module:
>>> import re
>>> href_link = 'link_to_disclaimer.html'
>>> if re.search(pattern, href_link):
... print('matches')
matches