Open tianles opened 6 years ago
<div class="detail-journey-head"> <i class="icon detail-journey-day">D1</i> <strong>第1天</strong> <strong>北京</strong> <i class="icon detail-journey-transport-train"></i> <strong>南京</strong> </div>
不管是css还是xpath,都没法精确取出 “南京”
.detail-journey-head > strong:nth-child(3)
怎么会哈,用xpath即可,写法如下: //div[contains(@class,'detail-journey-head')]/strong[3]
//div[@class='detail-journey-head']/strong[last()] 还可以这样写,给自己点赞~☺ 参考:
//div[@class='detail-journey-head']/strong[last()]
https://www.w3school.com.cn/xpath/xpath_syntax.asp
不管是css还是xpath,都没法精确取出 “南京”
.detail-journey-head > strong:nth-child(3)