summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2016-12-11 10:24:58 -0500
committerLeonard Richardson <leonardr@segfault.org>2016-12-11 10:24:58 -0500
commitad9e588d54561ed929e89b3433e75388e45366ae (patch)
treeda629fac7628bb0d22a209be3cdb4360a6cca365 /doc/source
parentb82474b190cf8b741c78a16cd9a80954e7ffae34 (diff)
Show how to use the attrs argument to search by the 'name' attribute. [bug=1639580]
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/index.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 654a3a4..cd1ab2f 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -1262,6 +1262,16 @@ dictionary and passing the dictionary into ``find_all()`` as the
data_soup.find_all(attrs={"data-foo": "value"})
# [<div data-foo="value">foo!</div>]
+Similarly for HTML's 'name' attribute, which you can't use as a
+keyword argument because Beautiful Soup uses the ``name`` argument to
+contain the name of the tag itself.
+
+ name_soup = BeautifulSoup('<input name="email"/>')
+ name_soup.find_all(name="email")
+ # []
+ name_soup.find_all(attrs={"name": "email"})
+ # [<input name="email"/>]
+
.. _attrs:
Searching by CSS class