tomsik68

lxml etree demo

May 24th, 2019
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. from lxml import etree
  2. import requests
  3.  
  4. resp = requests.get('http://www.1sg.sk/index.php?id=1110&node=0&datum=2019-05-24')
  5.  
  6. # resp.content je typu string
  7. html = etree.HTML(resp.content)
  8.  
  9. # tabulky je zoznam vsetkych tabuliek
  10. tabulky = html.xpath('//table')
  11.  
  12. for t in tabulky:
  13.     t.getparent().remove(t)
  14.  
  15. print(etree.tostring(html))
Advertisement
Add Comment
Please, Sign In to add comment