documentation : https://www.crummy.com/software/BeautifulSoup/bs4/doc/

BeautifulSoup Object

Beautiful Soup gives us a BeautifulSoup object, which represents the document as a nested data structure:

**from** **bs4** **import** BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')

Here are some simple ways to navigate that data structure:

soup.title
# <title>The Dormouse's story</title>
soup.title.name
# u'title'
soup.title.string
# u'The Dormouse's story'
soup.title.parent.name
# u'head'
soup.p
# <p class="title"><b>The Dormouse's story</b></p>
soup.p['class']
# u'title'
soup.a
# <a class="sister" href="<http://example.com/elsie>" id="link1">Elsie</a>
soup.find_all('a')
# [<a class="sister" href="<http://example.com/elsie>" id="link1">Elsie</a>,
#  <a class="sister" href="<http://example.com/lacie>" id="link2">Lacie</a>,
#  <a class="sister" href="<http://example.com/tillie>" id="link3">Tillie</a>]
soup.find(id="link3")
# <a class="sister" href="<http://example.com/tillie>" id="link3">Tillie</a>

Beautiful Soup is a Python library that is used for web scraping purposes to pull the data out of HTML and XML files. It creates a parse tree from page source code that can be used to extract data in a hierarchical and more readable manner.