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”]仅div.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"]')
您可以尝试以下方法:
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"]')