[英]Extract text from a DOM element in javascript casperjs
for(var i=0; i < 20; i++) {
this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') > div.one > div.two > div.three > span[class="ma-AdCard-price"]'));
}
有時在跨度之前有 2 個 div 而不是 3 個 div。 我需要始終從 div.ma-AdCardMyAds:nth-child('+1+') 開始達到 span[class="ma-AdCard-price"]
只有 div.one > div.three
this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') > div.one > div.three > span[class="ma-AdCard-price"]'));
不起作用
this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') > span[class="ma-AdCard-price"]')
你可以試試這個:
this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') span[class="ma-AdCard-price"]')
如果div.one
和div.two
始終存在,請使用:
this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') > div.one > div.two span[class="ma-AdCard-price"]')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.