phpspider icon indicating copy to clipboard operation
phpspider copied to clipboard

selector没法精确选取,不管是css还是xpath

Open tianles opened this issue 6 years ago • 2 comments

<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)

tianles avatar May 10 '18 03:05 tianles

怎么会哈,用xpath即可,写法如下: //div[contains(@class,'detail-journey-head')]/strong[3]

owner888 avatar Jul 16 '18 14:07 owner888

//div[@class='detail-journey-head']/strong[last()] 还可以这样写,给自己点赞~☺ 参考:

https://www.w3school.com.cn/xpath/xpath_syntax.asp

lypeng29 avatar Sep 06 '19 07:09 lypeng29