文章詳情頁
python3.x - python lxml無法查找第一個tag有鏈接和沒有內容tag的子tag的text?
瀏覽:62日期:2022-06-30 11:47:53
問題描述
第一個situation:tag內有link
from lxml import etree node = etree.fromstring(’<a xml = ’www.www.com’><c>bum</c></a>’)print node.findtext(’c’,default = ’what happened?’)
第二個situation:所求text所在tag上一級tag無content
from lxml import etree node = etree.fromstring(’<a><b><c>bum</c></b></a>’)print node.findtext(’c’, default = ’what happened?’)
以上兩個situation所返回的結果都是‘None’
成功的situation
from lxml import etree node = etree.fromstring(’<a><c>bum</c></a>’)print node.findtext(’c’)
想問一下這兩個問題應該怎么解決?
問題解答
回答1:給你推薦pyquery,個人認為更好用
相關文章:
1. phpStudy怎么把mysql升級到7.x2. python - flask jinjia2 中怎么定義嵌套變量3. centos - apache配置django報錯:cannot be loaded as Python modules4. angular.js - 百度支持_escaped_fragment_嗎?5. 大家都用什么工具管理mysql數據庫?6. vim下怎么把一大段代python碼往前移動一個tab?7. 數據庫 - mysql中有沒查看數據大小的函數??8. windows docker-machine port9. mysql優化 - mysql count(id)查詢速度如何優化?10. linux - 為什么我在mysql的my.cnf下找不到bind-address?
排行榜
