I am trying to use python and beautiful soup to extract the content part of the tags below:
&l
Provide the meta
tag name as the first argument to find()
. Then, use keyword arguments to check the specific attributes:
title = soup.find("meta", property="og:title")
url = soup.find("meta", property="og:url")
print(title["content"] if title else "No meta title given")
print(url["content"] if url else "No meta url given")
The if
/else
checks here would be optional if you know that the title and url meta properties would always be present.