CSS selector support for BeautifulSoup.
Pull request Compare This branch is 19 commits ahead of simonw: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('http://slashdot.org/'))
    >>> select(soup, 'div.title h3')
    <span><a href='//science.slashdot.org/'>Science</a>:</span> ...
    </h3>, <h3>
    <a href='//slashdot.org/articles/07/02/28/0120220.shtml'>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('http://slashdot.org/'))
    >>> soup.findSelect('div.title h3')