Skip to content

CSS code snippet – How to get elements with selector using beautifulsoup?

soup.select('div')
All elements named <div>

soup.select('#name')
The element with an id attribute of 'name'

soup.select('.note')
All elements that use a CSS class attribute named 'note'

soup.select('div span')
All elements named <span> that are within an element named <div>

soup.select('div > span')
All elements named <span> that are directly within an element named <div>, with no other element in between

soup.select('input[name]')
All elements named <input> that have a name attribute with any value

soup.select('input[type="button"]')
All elements named <input> that have an attribute named type with value button
See also  How to record youtube cc in Python?
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.