beautifulsoup grabs the class keyword

Here we want to filter by class, but class is the keyword of python , what should we do? Just add an underscore

1
2
3
4
soup . find_all ( "a" , class_ = "sister" )
# [<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>]

Guess you like

Origin blog.csdn.net/huochuangchuang/article/details/49742295