I'd like to clicks all links which contain some specific words, links (hrefs) are like:
what is blue
how to mix red with yellow
is pink dress good?
They are all links which I can click, but I only want to click titles with word 'blue' and 'pink', else, next link, so I do: but it just says no links contain the word
it is like a list = ['what is blue','how to mix red with yellow','is pink dress good?'] and I want to access all elements and check if element in list = ['blue','pink'] is it in it
list = ['what is blue','how to mix red with yellow','is pink dress good?']
list2 = ['blue','pink']
if any elements in list2 is also in list(hrefs), click it, else ignore it
Thank you for your time in advance!
word = {'blue','pink'}
links = [link.get_attribute('href') for link in driver.find_elements_by_xpath('')]
keywords= [keyword.get_attribute('innerHTML') for keyword in driver.find_elements_by_xpath('')]
for line in keywords:
if set(words).intersection(line.split(",")):
print("in it")
driver.get(link)
also I tried, I want like title contains sth like blue
keyword = driver.find_elements_by_xpath('//*[contains(@title, id)]')
the html looks like
<a href="/zbscbzw/isinbm/202101/6b958a0fae1f497f8ec65b60d64120d9.shtml" target="_blank" title="new issue blue thing">New issue blue thing</a>