xpath

1

selector.xpah("//*[@id='df']")

// 后面的*  所有的元素

2

call_form = selector.xpath("//*[@id='details_table']/tbody/tr")

选取这个tbody下的所有的tr

3

selector.xpah("//*[@id='df']/@value")

选取下面的value

4  输出一个节点下的   文字

kk = selector.xpath('//tr[@class="content2"]')
print kk
for i in kk:
print(i.xpath('string(.)'))

5 将一个节点下的内容转化成文字
kk = selector.xpath('//tr[@class="content2"]')
print kk[2]
ll = etree.tostring(kk[2],encoding='utf8')
print ll

posted on 2017-05-20 18:14  姜维天  阅读(93)  评论(0编辑  收藏  举报

导航