Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="push-half--bottom " itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
- <span itemprop="streetAddress">Zimmerbachstr. 51</span>,
- <span itemprop="postalCode">74676</span>
- <span itemprop="addressLocality">Niedernhall-Waldzimmern</span><br>
- <span itemprop="addressCountry">Germany</span><br>
- </div>
- from bs4 import BeautifulSoup
- content = """
- <div class="push-half--bottom " itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
- <span itemprop="streetAddress">Zimmerbachstr. 51</span>,
- <span itemprop="postalCode">74676</span>
- <span itemprop="addressLocality">Niedernhall-Waldzimmern</span><br>
- <span itemprop="addressCountry">Germany</span><br>
- </div>
- """
- soup = BeautifulSoup(content,"lxml")
- [country.extract() for country in soup.select("[itemprop='addressCountry']")]
- item = [item.get_text(strip=True) for item in soup.select("[itemprop='address']")]
- print(item)
Add Comment
Please, Sign In to add comment