Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- htmlelement = """
- <tbody>
- <tr style="">
- <td><a>27A-TAX DISTRICT</a> 27A</td>
- </tr>
- <tr style="">
- <td><strong>Parcel Number</strong> 720</td>
- </tr>
- </tbody>
- """
- soup = BeautifulSoup(htmlelement,"lxml")
- item = soup.select_one("tr:not(a)").text
- print(item)
- from bs4 import BeautifulSoup
- htmlelement = """
- <p class="vital">I should be printed</p>
- <p>I should not be printed</p>
- """
- soup = BeautifulSoup(htmlelement,"lxml")
- item = soup.select_one("p:has(.vital)").text
- print(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement