Skip to content

Instantly share code, notes, and snippets.

@shubham769
Created April 29, 2020 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubham769/3a5aa65d1d88d9a7608ae64af9cc73e0 to your computer and use it in GitHub Desktop.
Save shubham769/3a5aa65d1d88d9a7608ae64af9cc73e0 to your computer and use it in GitHub Desktop.
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment