84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
There is a piece of html code as follows:
<p class="col-9 d-inline-block text gray mb-2 pr-4"> My <em>Python</em> Examples </p>
What should I do if I want to use xpath to extract My Python Examples
Read more help documents!
//p[@class="col-9 d-inline-block text gray mb-2 pr-4"]/text()
Refer to this answer of mine:/q/10...
But I discovered a new method, p_dom.xpath("string()"),可以直接取出内容作为一个完整的字符串;然后就是lxml.etree中的方法:etree.tostring(p_dom, method='text'), but you still have to choose according to your needs.
p_dom.xpath("string()")
lxml.etree
etree.tostring(p_dom, method='text')
Read more help documents!
//p[@class="col-9 d-inline-block text gray mb-2 pr-4"]/text()
Refer to this answer of mine:/q/10...
But I discovered a new method,
p_dom.xpath("string()")
,可以直接取出内容作为一个完整的字符串;然后就是
lxml.etree
中的方法:etree.tostring(p_dom, method='text')
, but you still have to choose according to your needs.