Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

beautifulsoup find

htmlTag = soup.find(id="id")
text = soup.find(id="id").get_text()
Comment

beautiful soup find

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>
Comment

PREVIOUS NEXT
Code Example
Python :: what is admin.tabularinline django 
Python :: change excel value in python 
Python :: python - How to subtract values from dictionaries 
Python :: type() function in python 
Python :: all combinations 
Python :: closure python 
Python :: how to count number from 1 to 10 in python 
Python :: python lock file 
Python :: pandas df count values less than 0 
Python :: tuple push 
Python :: how to change series datatype from object to float 
Python :: find a character in a string python last 
Python :: star program in python using for loop 
Python :: numpy unique axis 
Python :: add row to dataframe 
Python :: Generate hashed passwords for ansible 
Python :: add two dataframes together 
Python :: Merge two Querysets in Python Django while preserving Queryset methods 
Python :: create list of dictionaries from list of list python 
Python :: python coding practice 
Python :: python library 
Python :: read one column pandas 
Python :: join function python 
Python :: mac big sur and python3 problems 
Python :: protected vs private python 
Python :: append to an array in 1st place python 
Python :: json payload python function 
Python :: sorted function in python 3 
Python :: create array with shape 0,2 
Python :: inheritance in python 3 example 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =