These methods use.previous_elements to iterate over the tags and strings that came before it in the document. The find_all_previous() method returns all matches, and find_previous() only returns the first match:
first_link = soup.afirst_link# <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>first_link.find_all_previous("p")# [<p class="story">Once upon a time there were three little sisters; ...</p>,# <p class="title"><b>The Dormouse's story</b></p>]first_link.find_previous("title")# <title>The Dormouse's story</title>
The call to find_all_previous("p") found the first paragraph in the document (the one with class=”title”), but it also finds the second paragraph, the