 <p>If you want to write something generic, you would still need to locate the next sibling tag/text node with <code>next_sibling</code> or <code>find_next_sibling</code>.</p> <p>Here is the code that would handle both cases - when there is an element after the label and the text node:</p> <pre><code>soup = BeautifulSoup(html, "html.parser") for label in soup.find_all("span", class_="pl"): value = label.find_next_sibling("span", class_="attrs") value = label.next_sibling.strip() if not value else value.get_text(strip=True) label = label.get_text(strip=True).strip(":") print(label, value) </code></pre> <p>Prints:</p> <pre><code>Director James Actor Tom Countries USA Language English </code></pre>