API to query DOM tree of HTML/XML document.
from selection import XpathSelector
from lxml.html import fromstring
html = '<div><h1>test</h1><ul id="items"><li>1</li><li>2</li></ul></div>'
sel = XpathSelector(fromstring(html))
print(sel.select('//h1')).text()
print(sel.select('//li').text_list()
print(sel.select('//ul').attr('id')
Run: pip install -U selection
Telegram English chat: https://t.me/grablab
Telegram Russian chat: https://t.me/grablab_ru