
1 imn1 Jul 11, 2014 a.xpath('//div/text()')[0] 试试 |
2 ggarlic Jul 11, 2014 这坑我也踩过 text是空的原因是:text不是你以为的意思(一个标签的text内容)。text在文档中的定义是 Text before the first subelement. This is either a string or the value None, if there was no text. 除了楼上的方法,你也可以用itertext()方法来遍历 |
3 binux Jul 11, 2014 a.xpath('//div')[0].text_content() |
4 fy OP 多谢几位 搞定了 |
5 pc10201 Jul 11, 2014 我为啥总觉得正则提取比xpath好呢? |
6 dingyaguang117 Jul 11, 2014 @pc10201 xpath 虽然会慢一点 不过写法简洁,而且准确性高 |