[英]How to get full text inside lxml element
I have the following html: 我有以下html:
<span class="episode">Episode: <a href="/title/tt2071912/">
!Que ve el Bisbe!</a>
(2011)
</span>
How would I get the year from this? 我将如何获得这一年? When I get the episode object, it only gives me the 'text' before the
<a>
: 当我获得情节对象时,它只给我
<a>
之前的“文本”:
result.cssselect('.episode')[0].text
'Episode: '
The best I have so far is: 到目前为止,我最好的是:
year = lxml.html.tostring(result.cssselect('.episode')[0]).split('(')[-1].split(')')[0]
使用封闭元素的.text
属性 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.