常用的路劲表达式:
<img src="https://pic4.zhimg.com/v2-0ea5d1dba9a1cf0c04695edbcfbc248b_b.jpg" data-caption="" data-size="normal" data-rawwidth="681" data-rawheight="464" class="origin_image zh-lightbox-thumb" width="681" data-original="https://pic4.zhimg.com/v2-0ea5d1dba9a1cf0c04695edbcfbc248b_r.jpg">
谓语被嵌在方括号内,用来查找某个特定的节点或包含某个制定的值的节点
实例:
<img src="https://pic3.zhimg.com/v2-0396b0b40df0f73214d2bc60a9d4af3e_b.jpg" data-caption="" data-size="normal" data-rawwidth="688" data-rawheight="368" class="origin_image zh-lightbox-thumb" width="688" data-original="https://pic3.zhimg.com/v2-0396b0b40df0f73214d2bc60a9d4af3e_r.jpg">
Xpath通过通配符来选取未知的XML元素
<img src="https://pic3.zhimg.com/v2-795be9470f73b5554e8effa98345a51e_b.jpg" data-caption="" data-size="normal" data-rawwidth="693" data-rawheight="148" class="origin_image zh-lightbox-thumb" width="693" data-original="https://pic3.zhimg.com/v2-795be9470f73b5554e8effa98345a51e_r.jpg">
使用“|”运算符可以选取多个路径
<img src="https://pic4.zhimg.com/v2-4efc24233e9bbd84183caaab66ed3283_b.png" data-caption="" data-size="normal" data-rawwidth="688" data-rawheight="103" class="origin_image zh-lightbox-thumb" width="688" data-original="https://pic4.zhimg.com/v2-4efc24233e9bbd84183caaab66ed3283_r.jpg">
轴可以定义相对于当前节点的节点集
<img src="https://pic3.zhimg.com/v2-d95dbad4d9badead1f3902f67b19b7c6_b.jpg" data-caption="" data-size="normal" data-rawwidth="690" data-rawheight="563" class="origin_image zh-lightbox-thumb" width="690" data-original="https://pic3.zhimg.com/v2-d95dbad4d9badead1f3902f67b19b7c6_r.jpg">
<img src="https://pic4.zhimg.com/v2-3b382478e98acaca043d56ea04ebb177_b.png" data-caption="" data-size="normal" data-rawwidth="684" data-rawheight="102" class="origin_image zh-lightbox-thumb" width="684" data-original="https://pic4.zhimg.com/v2-3b382478e98acaca043d56ea04ebb177_r.jpg">
使用功能函数能够更好的进行模糊搜索
<img src="https://pic1.zhimg.com/v2-26d54ba6e9175d6f26a0974dfccf6fdc_b.jpg" data-caption="" data-size="normal" data-rawwidth="696" data-rawheight="347" class="origin_image zh-lightbox-thumb" width="696" data-original="https://pic1.zhimg.com/v2-26d54ba6e9175d6f26a0974dfccf6fdc_r.jpg">
scrapy xpath文档:http://doc.scrapy.org/en/0.14/topics/selectors.html