tomsik68 icon

lxml etree demo

tomsik68 | PRO | 05/24/19 04:42:44 PM UTC | 0 ⭐ | 347 👁️ | Never ⏰ | []
Python |

340 B

|

None

|

0 👍

/

0 👎

from lxml import etree
import requests
 
resp = requests.get('http://www.1sg.sk/index.php?id=1110&node=0&datum=2019-05-24')
 
# resp.content je typu string
html = etree.HTML(resp.content)
 
# tabulky je zoznam vsetkych tabuliek
tabulky = html.xpath('//table')
 
for t in tabulky:
    t.getparent().remove(t)
 
print(etree.tostring(html))

Comments