语言 python ,怎么获取 tr 里的 name 和 td[last()]的 comment()的值,或者不用 XPaht 也可以..
<tr mot="hideTip" mor="showTip" ck="detailAccount" un="userline" name="张三" class="cursor_point" alias="[email protected]" href="#mbr/account/detail/[email protected],m=6859780" uid="2614939503"> <td class="name"> <span class="ico_move"></span> <input type="checkbox" name="alias" ck="checkThis" un="mbrCheck" title="选中 /取消选中" alias="[email protected]" uin="2614939503" mobile="" nickname="张三" active="1" close="0"> <span> <img class="icon_diff icon_man" src="https://res.mail.qq.com/bizmail/zh_CN/htmledition/images/spacer087795.gif" title="男"> <a un="name" class="" href="#mbr/account/detail/[email protected],m=6859780"> <span>张三</span></a> </span> </td> <td class="email"> <a href="#mbr/account/detail/[email protected],m=6859780"> <span>[email protected]</span></a> </td> <td> <span title="公司名称">公司名称</span></td> <td un="settop"> <a href="Javascript:;" style="display:none" title="当前部门内置顶" un="tip" ck="setTop" class="set_toTop btn_gray" partyuserid="798874"> <span>置顶</span></a> </td> <td> <!--open -1 off --></td> <td> <!--token 1 on --> <a href="Javascript:;" title="已启用微信动态密码" class="dynamic_pwd" partyuserid="798874"> <span></span> </a> </td> </tr>
![]() | 1 Hodor 2016-06-21 00:11:11 +08:00 bilibili |
2 pandada8 2016-06-21 00:29:51 +08:00 for i in tree.xpath("//tr[@name]"): print(i.attrib['name'], i.xpath("./td[last()]/comment()")[0]) |