简体   繁体   English

python,lxml以及如何从子集中获取html代码

[英]python, lxml and how to get html code from subset

I use this function to get this section of the html doc. 我用这个函数来获取html doc的这一部分。

for el in doc.find_class('plusShippingText'):
      print el

What I need is the html code. 我需要的是HTML代码。 How can I print the html code for el? 如何打印el的html代码?

Thanks 谢谢

使用lxml.html.tostring

print lxml.html.tostring(el)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM