我想要的东西:
Some text
Some other text
我得到了什么:
Some text
var s = 'javascript I don't want';
Some other text
我的代码
给定一个xpath选择器我正在使用以下函数来提取文本:
def getText(hxs):
if len(hxs) > 0:
l = hxs.select('string(.)')
if len(l) > 0:
s = l[0].extract().encode('utf-8')
else:
s = hxs[0].extract().encode('utf-8')
return s
else:
return 0
我尝试过使用XPath轴(像child :: script这样的东西),但无济于事.