summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorIsaac Muse <isaacmuse@gmail.com>2018-12-19 19:13:02 -0700
committerIsaac Muse <isaacmuse@gmail.com>2018-12-19 19:13:02 -0700
commit72923b4f95a0b96d0cf598cd1ecce27b596bf017 (patch)
tree4ea03d956d51d888c32c0e74c77dca2426eb2b9c /doc/source
parent427a877bc1a02fa95d83ac2500f94cba2e91501f (diff)
Add Soup Sieve support
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/index.rst29
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 73a288b..f1a006e 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -1662,9 +1662,10 @@ tag it contains.
CSS selectors
-------------
-Beautiful Soup supports the most commonly-used CSS selectors. Just
-pass a string into the ``.select()`` method of a ``Tag`` object or the
-``BeautifulSoup`` object itself.
+Beautiful Soup supports a large number of CSS selectors via `Soup Sieve
+<https://github.com/facelessuser/soupsieve>`_, only a small portion will be
+discussed here. To select tags, just pass a string into the ``.select()`` method
+of a ``Tag`` object or the ``BeautifulSoup`` object itself.
You can find tags::
@@ -1780,11 +1781,29 @@ Find only the first tag that matches a selector::
soup.select_one(".sister")
# <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>
+You can also use namespaces as well, provided you define namespaces::
+
+ import bs4
+ xml = """<tag xmlns:xyz=http://namespaceuri.com/namespace">
+ <xyz:el>...</xyz:el>
+ </tag> """
+ namespaces = {"xyz": "http://namespaceuri.com/namespace"}
+ soup = bs4.BeautifulSoup(xml, "lxml-xml")
+ soup.select("xyz|el")
+ # [<el>...</el>]
+
+As Soup Sieve is inlcuded with Beautiful soup, you can also use it directly
+on ``BeautifulSoup`` and ``Tag`` objects.
+
This is all a convenience for users who know the CSS selector syntax. You
can do all this stuff with the Beautiful Soup API. And if CSS
selectors are all you need, you might as well use lxml directly: it's
-a lot faster, and it supports more CSS selectors. But this lets you
-`combine` simple CSS selectors with the Beautiful Soup API.
+a lot faster. But this lets you `combine` complex CSS selectors with the
+Beautiful Soup API.
+
+To learn more about all the CSS selectors supported, or to learn how to use
+SoupSieve's API directly, checkout its `documentation
+<https://facelessuser.github.io/soupsieve/>`_.
Modifying the tree