How to get HTML page meta description with BeautifulSoup and Python?
In Python, the simplest way to get page description with BeautifulSoup is to use the following syntax:
from bs4 import BeautifulSoup
soup = BeautifulSoup(htmlStr, features="html5lib")
# Find description in meta <meta name="description"...
description = soup.find("meta", attrs={'name':'description'})
print (description["content"])
# Find description in meta <meta property="og:description" ...
description = soup.find("meta", property="og:description")
print (description["content"])
In Python, the simplest way to get page description with BeautifulSoup is to use the following syntax:
from bs4 import BeautifulSoup
soup = BeautifulSoup(htmlStr, features="html5lib")
# Find description in meta <meta name="description"...
description = soup.find("meta", attrs={'name':'description'})
print (description["content"])
# Find description in meta <meta property="og:description" ...
description = soup.find("meta", property="og:description")
print (description["content"])
# | ID | Query | URL | Count |
---|