Skip to the content
九天博客

下载综合症

  • 教程
  • 分享
  • 视频
  • 常用影视接口
  • 影视导航
  • 视频解析
  • Aria2下载
  • 在线M3U8播放器
  • 教程
  • 分享
  • 视频
  • 常用影视接口
  • 影视导航
  • 视频解析
  • Aria2下载
  • 在线M3U8播放器

xpath的contains使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#它会取class含有有test1和test2的元素
xpath('//div[contains(@class,"test1") and contains(@class,"test2")]')
#它会取class 含有 test1 或者test2满足时,或者同时满足时的元素
xpath('//div[contains(@class,"test1") or contains(@class,"test2")]')
查找name属性中包含zhangsan关键字的页面元素
//divt[contains(@name,'zhangsan')]
xpath写法为 //a[text()='百度搜索'] 或者 //a[contains(text(),"百度搜索")]
<a href="http://www.baidu.com">百度搜索</a>
#开闭标签之间的文本内容
//a[contains(@class,"news-item-title")]/text()  
#选中标签节点中获取指定属性的值
//a[contains(@class,"news-item-title")]/@href  
# 选取class属性包含ing的href链接地址
html.xpath("//div/p[2][contains(@class,'ing')]/a/@href")
# 选取价格大于20元书的价格值
html.xpath("//book[price>20.00]/price/text()")
# 选取前2本书
html.xpath("//book[position()<3]/title/text()")
#取div位置大于2的 并且类包含three的
html.xpath("//div[position()>2 and contains(@class,'three')]/@class")
# 豆瓣电影评分大于8的电影
//span[@class="rating_nums"][text()>8]
#xpath定位标签中最后一个元素 last()
//span[@class="comment-info"]//span[last()]
#xpath定位标签中倒数第二个元素 last()
//span[@class="comment-info"]//span[last()-1]
#列表下一页 text()
//div[@class="m-page"]/a[contains(text(),'下一页')]
#在路径表达式中使用"|"运算符,您可以选取若干个路径。
#选取 book 元素的所有 title 和 price 元素。
//book/title | //book/price
#选取文档中的所有 title 和 price 元素。
//title | //price
#选取属于 bookstore 元素的 book 元素的所有 title 元素,以及文档中所有的 price 元素。
//bookstore/book/title | //price

 

九天

下载综合征重度患者,已进入晚期。

Author archive Author website

2024年3月30日

教程

Previous post Next post

发表评论 取消回复

要发表评论,您必须先登录。

近期文章

  • OK影视apk
  • 密码保护:破解
  • Linux 网络流量监控利器 iftop 中文入门指南
  • 西瓜播放器
  • PHP简单的获取用户IP,系统,浏览器等信息

分类目录

  • 分享 (45)
  • 教程 (102)
  • 日常 (6)
  • 视频 (3)
  • 软件 (2)

标签

BT (1) C# (12) FFmpeg (3) GIF (1) JSON (2) linux (2) m3u8 (1) mysql (10) Nginx (1) PHP (10) PS (1) python (5) SRT (1) TS (1) VTT (1) 下载 (4) 九天 (1) 云监控 (1) 代码 (1) 免费 (1) 动图 (1) 合并 (2) 域名 (1) 字幕 (1) 字符串 (1) 录制 (1) 提取数字 (1) 搜索 (1) 教程 (2) 数字 (1) 数据库 (8) 时区 (1) 模糊查询 (1) 正则 (1) 番号 (1) 短信 (1) 磁力 (2) 种子 (2) 类 (2) 绿色 (1) 解密 (1) 迅雷 (1) 重复 (2) 随机 (1) 高速通道 (1)

近期评论

  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • 九天发表在《网友留言》
  • buy viagra发表在《这20张图能治愈最严重的强迫症患者》

九天系列

  • 1024超级搜索
  • 音乐解析

热门文章

  • EXCEL对身份证号进行信息提取
  • C#教程目录
  • 超级好用动图录制工具GIFCam2.0

联系我

留言板

© 2025 九天博客 — Powered by WordPress

Theme by Anders Noren — Up ↑