I am parsing HTML text with
Telephone = soup.find(itemprop="telephone").get_text()
In the case a Telephone number is in the HTML after the itemprop tag, I receive a number and get the output ("Telephone Number: 34834243244", for instance).
Of course, I receive AttributeError: 'NoneType' object has no attribute 'get_text' in the case no telephone number is found. That is fine.
However, in this case I would like Python not to print an error message and instead set Telephone = "-" and get the output "Telephone Number: -".
Can anybody advise how to handle this error?
is Nonebeforehand; ortryand catch theAttributeError.