From 144de8366f760bbafe2351947e92eeae8407371d Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Wed, 10 Dec 2014 19:01:46 -0500 Subject: The select() method now supports selector grouping. Patch by Francisco Canas [bug=1191917] --- doc/source/index.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'doc') 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") # [Lacie] +Find tags that match any selector from a list of selectors: + + soup.select("#link1,#link2") + # [Elsie, + # Lacie] + Test for the existence of an attribute:: soup.select('a[href]') @@ -1729,7 +1735,8 @@ Match language codes:: #

Howdy, y'all

, #

Pip-pip, old fruit

] -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 -- cgit v1.2.1