summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2014-12-10 19:01:46 -0500
committerLeonard Richardson <leonardr@segfault.org>2014-12-10 19:01:46 -0500
commit144de8366f760bbafe2351947e92eeae8407371d (patch)
treef457496c82afe0878e134e7ee76893b6cd9e07af /doc
parente2b76538144efabd5e1c7958716bb1fb3451d399 (diff)
downloadbeautifulsoup4-144de8366f760bbafe2351947e92eeae8407371d.tar.gz
The select() method now supports selector grouping. Patch by
Francisco Canas [bug=1191917]
Diffstat (limited to 'doc')
-rw-r--r--doc/source/index.rst13
1 files changed, 10 insertions, 3 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 5d067ea..4f3bd0b 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -552,7 +552,7 @@ Here's the "Three sisters" HTML document again::
"""
from bs4 import BeautifulSoup
- soup = BeautifulSoup(html_doc)
+ soup = BeautifulSoup(html_doc, 'html.parser')
I'll use this as an example to show you how to move from one part of
a document to another.
@@ -1009,7 +1009,7 @@ Once again, I'll be using the "three sisters" document as an example::
"""
from bs4 import BeautifulSoup
- soup = BeautifulSoup(html_doc)
+ soup = BeautifulSoup(html_doc, 'html.parser')
By passing in a filter to an argument like ``find_all()``, you can
zoom in on the parts of the document you're interested in.
@@ -1692,6 +1692,12 @@ Find tags by ID::
soup.select("a#link2")
# [<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>]
+Find tags that match any selector from a list of selectors:
+
+ soup.select("#link1,#link2")
+ # [<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
+ # <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>]
+
Test for the existence of an attribute::
soup.select('a[href]')
@@ -1729,7 +1735,8 @@ Match language codes::
# <p lang="en-us">Howdy, y'all</p>,
# <p lang="en-gb">Pip-pip, old fruit</p>]
-This is a convenience for users who know the CSS selector syntax. You
+
+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