How to deal with statements in http document format with Xpath directly under Python?

under the web page loaded by Ajax, manually copy something similar to < tbody > < tr class= "abcdefg" > < td > 1 < / td > < td > 3 < / td > < / tr > < / tbody >;

after copying this type of text, how do you convert it to a format that xpath can handle?

if you use the assignment statement directly, you will get a str type, which cannot be parsed directly with xpath to get

.

for example, I want to get the content of
name=text.xpath (". / td") [1] .text
this element,

if you directly use text= "< tbody > < tr class=" abcdefg "> < td > 1 < / td > < td > 3 < / td > < / tr > < / tbody >", you will report an error

.

SyntaxError: invalid syntax

Mar.06,2021

from lxml import etree


html = etree.HTML(text)
Menu