Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2.  
  3. htmlelement = """
  4. <tbody>
  5. <tr style="">
  6. <td><a>27A-TAX DISTRICT</a> 27A</td>
  7. </tr>
  8.  
  9. <tr style="">
  10. <td><strong>Parcel Number</strong> 720</td>
  11. </tr>
  12. </tbody>
  13. """
  14. soup = BeautifulSoup(htmlelement,"lxml")
  15. item = soup.select_one("tr:not(a)").text
  16. print(item)
  17.  
  18. from bs4 import BeautifulSoup
  19.  
  20. htmlelement = """
  21. <p class="vital">I should be printed</p>
  22. <p>I should not be printed</p>
  23. """
  24. soup = BeautifulSoup(htmlelement,"lxml")
  25. item = soup.select_one("p:has(.vital)").text
  26. print(item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement