网页块元素定位建议使用的xpath方式


取上图的新手上路文字
使用xpath

"//div[@class='pbm mbm bbda cl']//li[contains(string(),'用户组')]/span/a/text()"

其他参考方案,使用兄弟节点

 user_group = response.xpath("//div[@class='pbm mbm bbda cl']//em[contains(text(), '用户组')]/following-sibling::*[1]/a/text()").extract()[0]
posted @ 2019-01-30 17:24  公众号python学习开发  阅读(303)  评论(0编辑  收藏  举报