从javascript casperjs中的DOM元素中提取文本

问题描述 投票:0回答:1
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"]'));

}

[有时,在span之前为2 div,而不是3 div。我需要始终从div.ma-AdCardMyAds:nth-​​child('+ 1 +')

开始达到span [class =“ ma-AdCard-price”]

仅d​​iv.one> div.3

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"]')
javascript casperjs
1个回答
0
投票

您可以尝试以下方法:

this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') span[class="ma-AdCard-price"]')

如果div.onediv.two始终在那儿,请使用:

this.fetchText('div.ma-AdCardMyAds:nth-child('+i+') > div.one > div.two span[class="ma-AdCard-price"]')
© www.soinside.com 2019 - 2024. All rights reserved.