我想找到所有类为'srpCards'且不包含src为https://exmple.com/hotelsnew/static/images/soldOut.png的特定img的部分,我在xpath下尝试过,但没有一个起作用。
//section[contains(@class,'srpCards') and not(contains(.//img[@src='https://expample.com/hotelsnew/static/images/soldOut.png']))]
//section[contains(@class,'srpCards') and not(contains(@src,'https://exmple.com/hotelsnew/static/images/soldOut.png']))]
下面是html
<section class="srpCards">
<div class="col-md-4 col-sm-4 col-xs-12 pad0 posRel">
</a>
<div id="srpCarousel" class="dn"><img src="" class="width100 fl dn" height="230"></div>
<!-- react-text: 26273 --><!-- /react-text -->
<div class="htlTypeTags dn">
<div class="htlTypeTagsInner">
<span class="tagText">Family</span>
<span class="tagText">Groups</span>
</div>
</div>
<div class="shortlist dn">
<a href="javascript:void(0);" class="fl">
<i class="icon-heart fl ico18 outrHrt"></i>
</a>
</div>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 padL15">
<div class="width100 fl">
<div class="col-md-12 col-sm-12 col-xs-12 pad0">
<div class="col-md-9 col-sm-9 pad0">
<div class="width100 fl ico20">
<span class="fl ico20 blue padR20 lh1-2 fmed">
<!-- react-text: 26288 -->Durga Guest House<!-- /react-text -->
<span class="dib padT5 padL15"><span class="fl padR5 ico11 grey padT2"></span>
</span>
</span>
</a>
<p class="width100 fl greyLt ico14 padT2 padB5">
<span class="fl padR5">
<!-- react-text: 26293 -->Area : <!-- /react-text --><!-- react-text: 26294 -->Wakad<!-- /react-text -->
</span>
<!-- react-text: 26295 --><!-- /react-text -->
</p>
<!-- react-text: 26296 --><!-- /react-text -->
</div>
</div>
<div class="col-md-3 col-m-3 pad0 fr txtRight curPos" style="display: flex; justify-content: flex-end;">
<div>
<div class="fr txtRight">
<i class="icon-reverse-go ico22 lh1-2 orange fl"></i>
<span class="ratingNum orange">
<span class="fb">2.5</span><!-- react-text: 26303 -->/5<!-- /react-text -->
</span>
</div>
<span class="fr txtRight blue ico13 padT4 marginT2 padL15">
<!-- react-text: 26305 -->38<!-- /react-text --><!-- react-text: 26306 --> reviews<!-- /react-text -->
</span>
</div>
</div>
</div>
<div class="width100 fl padT10">
<div class="col-md-6 col-sm-6 pad0"></div>
<!-- react-text: 26309 --><!-- /react-text -->
</div>
<div class="width100 fl marginT10">
<div class="col-md-7 col-sm-7 pad0 marginB5">
<div class="width100 fl"><span class="tooltipped tooltipped-n fl marginR15" data-tooltip-label="Room Service"><i class="icon-service2 ico24 fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Gym/Spa"><i class="icon-gym2 ico26 fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Internet Access"><i class="icon-wifi3 ico24 fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Restaurant"><i class="icon-restaurant2 ico24 fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Swimming Pool"><i class="icon-swimming2 ico26 fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Free Internet"><i class="icon-wifi-free ico24 fl blue"></i></span></div>
<div class="roomTypeSrp dn">
<div class="roomTypeSrpInner">
<span class=" fl width100 ico12 blue"></span>
<ul></ul>
</div>
</div>
</div>
<div class="col-md-5 col-sm-5 pad0 txtRight marginB10">
<div class="width100 fl txtRight"></div>
<div>
<div class="width100 fl txtRight">
<p class="greyDr fr ico20 fb"><img src="https://example.com/hotelsnew/static/images/soldOut.png"></p>
</div>
</div>
<span class="width100 fr txtRight marginT5 ico12 fmed greyDr"></span>
<div class="width100 fl txtRight marginT10"><button class="button orange fr">Show Detail</button></div>
</div>
<!-- react-text: 26338 --><!-- /react-text -->
</div>
</div>
</div>
</section>
答案 0 :(得分:2)
靠近你的地方,<img>
是死者,而不是<section>
的一部分
//section[contains(@class,'srpCards') and not(//img[contains(@src,'https://example.com/hotelsnew/static/images/soldOut.png')])]
答案 1 :(得分:0)
你很近。 <section>
个节点似乎只有一个 class 作为 srpCards 。因此,要查找所有类别为 srpCards 的部分,而忽略<img>
属性为src
的{{1}},则可以使用以下xpath:
https://exmple.com/hotelsnew/static/images/soldOut.png
如果//section[@class='srpCards' and not(.//img[contains(@src, 'soldOut')])]
节点可能包含除<section>
以外的更多类属性,则可以使用以下解决方案:
srpCards