🔵 🔵 🔵


Primary

၊၊||၊|။

Tag.find_all_next() ⚬|Documentation|1st|20260122170548-00-⌔

Beautiful Soup Documentation — Beautiful Soup 4.4.0 documentation#find-all-next-and-find-next

find_all_next() and find_next()

Signature: find_all_next(name, attrs, string, limit, ﹡﹡kwargs)

Signature: find_next(name, attrs, string, ﹡﹡kwargs)

These methods use.next_elements to iterate over whatever tags and strings that come after it in the document. The find_all_next() method returns all matches, and find_next() only returns the first match:

first_link = soup.a
first_link
# <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>
 
first_link.find_all_next(string=True)
# [u'Elsie', u',\n', u'Lacie', u' and\n', u'Tillie',
#  u';\nand they lived at the bottom of a well.', u'\n\n', u'...', u'\n']
 
first_link.find_next("p")
# <p class="story">...</p>

In the first example, the string “Elsie” showed up, even though it was contained within the tag we started from. In the second example, the last

tag in the document showed up, even though it’s not in the same part of the tree as the tag we started from. For these methods, all that matters is that an element match the filter, and show up later in the document than the starting element.

Printed 2026-06-28.

(echo:: @ )

Link to original

Secondary

• • •