亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python里面的xpath string 方法報錯

python里面的xpath string 方法報錯

侃侃爾雅 2018-07-18 13:47:30
tr_list = self.driver.find_elements_by_xpath('//table[@class="hyreport-table tl"]/tbody//tr')     for i in range(0,100):           for i  in range(0,len(tr_list)):                 content=etree(tr_list[i]).xpath("string(//*[@class='pl20'])")                 source=etree(tr_list[i]).xpath('//td[@class="ellipsis"]/span/text()')                 size=etree(tr_list[i]).xpath('//td[5]/text()')                 report_time=etree(tr_list[i]).xpath('//td[6]/text()')                 print("獲取內容為:下面打印的內容") Traceback (most recent call last):      File "qimingpian.py", line 115, in <module>         qimingpian().get_content()      File "qimingpian.py", line 92, in get_content         content=etree(tr_list[i]).xpath("string(//*[@class='pl20'])")     TypeError: 'module' object is not callable
查看完整描述

2 回答

?
SMILET

TA貢獻1796條經驗 獲得超4個贊

看起來好像是用的selenium,這里取子節點的話我記得是直接tr_list[i].find_element_by_xpath() 就行了, 如果etree是從lxml導入的話我記得是不能這樣寫的。。

查看完整回答
反對 回復 2018-07-18
?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

etree 我都是這么用的, 給你參考下

from lxml import etree   # 導入selector = etree.HTML(str("HTML內容")) 
result= selector.xpath('//div[@class="WB_handle"]//li[2]//em[2]/text()')


查看完整回答
反對 回復 2018-07-18
  • 2 回答
  • 0 關注
  • 778 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號