Here is what the official documentation says: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#going-down
In real documents, the .next_sibling or .previous_sibling tag will usually have a string containing spaces. Back to the Three Sisters document:
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a> <a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> <a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
You might think that the .next_sibling of the first tag will be the second tag. But actually its line: a comma and a new line that separate the first tag from the second:
link = soup.a link # <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a> link.next_sibling # u',\n'
The second tag is a .next_sibling comma:
link.next_sibling.next_sibling # <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>
Yura source share