I have a piece of HTML where I don't know how I can extract the element I am looking for:
from bs4 import BeautifulSoup
s = (
'<span class="price"><span class="mobile">Preis</span>\n'
+ '<span class="currency">CHF</span><span class="amount">110\'000</span></span>\n'
+ '<span class="region"><span class="mobile">Region</span>Ganze Schweiz</span>\n'
+ '<span class="branch"><span class="mobile">Branche</span>Gewerbe, Industrie</span>\n'
)
print(s)
soup = BeautifulSoup(s)
c = soup.find("span", class_="region")
Please note that the HTML code is incomplete, there is a <span> missing, that's a mistake on the page I am scraping.
The element I want to extract is "Ganze Schweiz" (and the corresponding other fields, "100'000" and "Gewerbe, Industrie").
Using c.find_all('span') will only get me "Region", but not the second part. I don't want to just replace "Region" with an empty string and use .text, because I have multiple lines with different words in place of "Region", so something more generic would be helpful.
Thanks for the help!