XPATH CSS PATH CHEAT SHEET
来源:互联网 发布:淮南大数据公司 编辑:程序博客网 时间:2024/04/30 11:19
# child::nodename 选取所有属于当前节点的 book 子元素,等价于 './nodename'>>> root.xpath('child::book')[<Element book at 0x2d888c8>, <Element book at 0x2d88878>]>>> root.xpath('./book')[<Element book at 0x2d888c8>, <Element book at 0x2d88878>]# attribute::lang 选取当前节点的 lang 属性,等价于 './@lang'>>> root.xpath('//*[@lang]')[0].xpath('attribute::lang')['eng']>>> root.xpath('//*[@lang]')[0].xpath('@lang')['eng']# child::* 选取当前节点的所有子元素,等价于 './*'>>> root.xpath('child::*')[<Element book at 0x2d88878>, <Element book at 0x2d88738>]>>> root.xpath('./*')[<Element book at 0x2d88878>, <Element book at 0x2d88738>]# attribute::* 选取当前节点的所有属性,等价于 './@*'>>> root.xpath('//*[@*]')[0].xpath('attribute::*')['eng']>>> root.xpath('//*[@*]')[0].xpath('@*')['eng']# child::text() 选取当前节点的所有文本子节点,等价于 './text()'>>> root.xpath('child::text()')['\n ', '\n ', '\n']>>> root.xpath('./text()')['\n ', '\n ', '\n']# child::node() 选取当前节点所有子节点,等价于 './node()'>>> root.xpath('child::node()')['\n ', <Element book at 0x2d88878>, '\n ', <Element book at 0x2d88738>, '\n']>>> root.xpath('./node()')['\n ', <Element book at 0x2d88878>, '\n ', <Element book at 0x2d88738>, '\n']# descendant::book 选取当前节点所有 book 后代,等价于 './/book'>>> root.xpath('descendant::book')[<Element book at 0x2d88878>, <Element book at 0x2d88738>]>>> root.xpath('.//book')[<Element book at 0x2d88878>, <Element book at 0x2d88738>]# ancestor::book 选取当前节点所有 book 先辈>>> root.xpath('.//title')[0].xpath('ancestor::book')[<Element book at 0x2d88878>]# ancestor-or-self::book 选取当前节点的所有 book 先辈以及如果当前节点是 book 的话也要选取>>> root.xpath('.//title')[0].xpath('ancestor-or-self::book') [<Element book at 0x2d88878>]>>> root.xpath('.//book')[0].xpath('ancestor-or-self::book')[<Element book at 0x2d88878>]>>> root.xpath('.//book')[0].xpath('ancestor::book')[]# child::*/child::price 选取当前节点的所有 price 孙节点,等价于 './*/price'>>> root.xpath('child::*/child::price')[<Element price at 0x2d88878>, <Element price at 0x2d88738>]>>> root.xpath('./*/price')[<Element price at 0x2d88878>, <Element price at 0x2d88738>]
阅读全文
0 0
- XPATH CSS PATH CHEAT SHEET
- Python selenium —— XPath and CSS cheat sheet
- 19、Selenium + Python 实现 UI 自动化测试-XPath and CSS cheat sheet
- CSS Shorthand Cheat Sheet by Example
- Cheat Sheet
- Cheat Sheet
- 关于“cheat sheet”
- regular expressions cheat sheet
- Vim Cheat Sheet
- vi vim cheat sheet
- Rails Migration Cheat Sheet
- Watir Cheat Sheet
- WinDbg / SOS Cheat Sheet
- PHP Cheat Sheet
- SQL Injection Cheat Sheet
- sql injection cheat sheet
- Input Validation Cheat Sheet
- Git Cheat Sheet
- org.hibernate.exception.SQLGrammarException: could not execute batch
- 10 个非常有用的 SVG 动画的 JavaScript 库
- linux下静态库和动态库的创建和使用
- oracle汉字转拼音(获得全拼/拼音首字母/拼音截取等)
- Android中Context详解 ---- 你所不知道的Context
- XPATH CSS PATH CHEAT SHEET
- 负数的二进制处理
- 父类私有变量是否被子类继承详细解说(答案:内存中存在,但sun公司定义为不继承)
- Java设置session超时(失效)的三种方式
- UVA 507 Jill Rides Again
- crontab 重定向错误日志 加上时间
- submit提交时刷新到iframe中,从而使主页面不被刷新。
- std::bind 浅析
- 广义线性模型