I need to create an "if statement" to check if the string "cette entreprise est membre de la FVE" is part of the a web page.
item_url = "http://www.fveconstruction.ch/anDetails.aspRT=2&M=01&R=1&ID=42105701"
response = requests.get(item_url)
soup = BeautifulSoup(response.text, 'html.parser')
test = soup.findAll(text = re.compile('cette entreprise est membre de la FVE.\w+..\w+'))
print(test)
And it prints me an empty list. Is there someone with an idea? And I would like to know how to check the statement? If I write :
if soup.findAll(text = re.compile('cette entreprise est membre de la FVE.\w+..\w+')):
do smth
else:
do smth
If there isn't the string I'm looking for, it supposed to return false right?
'text' in response.text?findAllreturns an empty list, it will be treated as false and the code will go to theelse..findAll()... It's best to use.find_all()if you're using BS4 because findAll is from bs3