Answer the question
In order to leave comments, you need to log in
How to compose an xpath query in python?
r = s.get(url, headers=headers)
tree = html.fromstring(r.text)
our_path = f'//*[@data-id="{data_id}"]'
a = tree.xpath(our_path)
b = tree.xpath('//title/text()')
[<Element tr at 0x16544a82590>, <InputElement 16544a82040 name=None type='checkbox'>] None
Answer the question
In order to leave comments, you need to log in
So you got the elements - take and get data from there ...
At least the text a[0].text , at least the contents of the tags a[0].get('tag') , at least the element itself in text form entirely using etree.tostring (a[0], pretty_print=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question