I'm trying to determine whether or not a list of URLs contain specific words. Below is my code:
url_list = ['website1.com', 'website2.com']
cci_words = ['Risk Management', 'Labor', 'Migrant Workers']
total_words = []
for url in url_list:
r = requests.get(url, allow_redirects=False)
soup = BeautifulSoup(r.content.lower(), 'lxml')
words = soup.find_all(text=lambda text: text and cci_words.lower() in text)
count = len(words)
cci_words = [ ele.strip() for ele in words ]
for word in words:
total_words.append(word.strip())
print('\nUrl: {}\ncontains {} of word: {}'.format(url, count, cci_words))
print(cci_words)
#print(total_words)
total_count = len(total_words)
But I keep getting this error: AttributeError: 'list' object has no attribute 'lower'
Any ideas what should I do??