Skip to content


Subversion checkout URL

You can clone with
Download ZIP
CSS selector support for BeautifulSoup.
Branch: master
Pull request Compare This branch is even with jhg:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A single function, select(soup, selector), that can be used to select items
from a BeautifulSoup instance using CSS selector syntax.

Currently supports type selectors, class selectors, id selectors, attribute
selectors, the descendant combinator and the immediate child (`>`) combinator.

This branch of soupselect requires BeautifulSoup 4.0 or above; it will not work
with v2.x or v3.x.

Example usage:
    >>> from bs4 import BeautifulSoup as Soup
    >>> from soupselect import select
    >>> import urllib
    >>> soup = Soup(urllib.urlopen(''))
    >>> select(soup, 'div.title h3')
    <span><a href='//'>Science</a>:</span> ...
    </h3>, <h3>
    <a href='//'>Star Trek To ...
    ... ]

You can also monkey-patch the BeautifulSoup class itself:

    >>> from bs4 import BeautifulSoup as Soup
    >>> import soupselect; soupselect.monkeypatch()
    >>> import urllib
    >>> soup = Soup(urllib.urlopen(''))
    >>> soup.findSelect('div.title h3')
Something went wrong with that request. Please try again.