summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2015-06-25 21:41:23 -0400
committerLeonard Richardson <leonardr@segfault.org>2015-06-25 21:41:23 -0400
commitc7b7a22a46064c6362eebb5670022b06bf601daf (patch)
tree6f8a994f6461b5e57b55278282fd72a1128473ac /doc/source
parent51044d613cc782d883a6eb3cd0d3dc391e13c23b (diff)
Introduced the select_one() method, which uses a CSS selector but
only returns the first match, instead of a list of matches. [bug=1349367]
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/index.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index d35481e..1b7b1e6 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -1735,6 +1735,10 @@ Match language codes::
# <p lang="en-us">Howdy, y'all</p>,
# <p lang="en-gb">Pip-pip, old fruit</p>]
+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>
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