我需要通过 xpath 检测一个元素(带有 href 的图像),但我只知道 href 的一部分
这是html
<a href="/play.php?video=123456">
<div class="video-splash" data-src="https://myimge-555888.jpg?md5=dfgdfsdgsowVf0QnDcAg&expires=16018841600&origin=103&mid=0df2fd8d-85b1-47da-a371-489a7328ffb4">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 43:25</div>
</div>
</a>
我知道视频 123456(href 的一部分)
视频号周期性变化
data-src 定期更改
我尝试了这些 xpath,但在这种情况下不起作用
xpath=//a[contains(@href, "123456")]
xpath=//a[ends-with(@href, '123456')]/img
xpath=//a[contains(@href, '123456')]/img
如何仅使用 href 的一部分检测元素?
我只需要一个可以检测到元素的 xpath。
需要一个通用的 xpath,因为某些属性是动态的video=???
,data-src=???
并且<b>???</b> ??? </div>
???总是变化的动态值,我需要通过视频编号来检测它。
我添加了更多的html代码
<div>
<h2 class="page-h2">
Performer <b>username</b> — Recent Recordings
</h2>
<div class="video-thumb">
<a href="/play.php?video=550420">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,29-59.jpg?md5=BV75Ney9jydwiZgdITkjSg&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 59:25</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">22.5K views</span> • 2020-04-25 29:59</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=529055">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,02-00.jpg?md5=d2GDbtiHuKT-by9A9qcMIA&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 45:25</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">20.0K views</span> • 2020-04-25 02:00</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=529725">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-24,29-55.jpg?md5=RrwtygDUT_zxTPf4mC2KAw&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 2:02:29</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">20.9K views</span> • 2020-04-24 29:55</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=527092">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,22-00.jpg?md5=unQIgoVWLXy5cBH4sPVWUw&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 20:52</div>
</div>
</a>