summaryrefslogtreecommitdiff
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
commitcf7750630e32978c0095ee5ec4ea9206a35665de (patch)
tree0f50108745f3b07687571df06d02f074c7aca6f3
parent264d1b9184ba5acb2cae3b7f8aa083da50975468 (diff)
downloadbeautifulsoup4-cf7750630e32978c0095ee5ec4ea9206a35665de.tar.gz
Show how to use the attrs argument to search by the 'name' attribute. [bug=1639580]
-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