无法从嵌套的div中提取文本

时间:2018-11-22 19:20:21

标签: xpath css-selectors casperjs

我有一个使用div而不是表格的网站的div(不是我的网站)。

这基本上是一个现场比分网站。有一个具有ID的主div,所有列div(分数,计时,黄牌等)都作为嵌套div出现在该主div下。

我正在尝试从所有嵌套的div中获取所有文本,但无法这样做,至少不能这样做。 这是我尝试过的: this.fetchText(x('// div [@ data-statustype =“ live”] // *'))。trim()。replace(/ \ n / gm,“”)

这将返回一些信息,但来自不同div的文本之间没有任何空格。

例如:DENMARK4RMARIENLYST BRONDBY 1313的20:00H / TH / THSHW游戏

请帮助! 这是代码的一部分::

    <div id="1631587" class="match_line score_row live_match     o_true" data-cntr="4" data-parent-competition="FA CUP" data-note="Knock out." data-competition-name="FOURTH ROUND" data-visible="true" data-league-type="PHASE" data-season="2018/2019" data-statustype="live" data-ko="23:30" data-home-team="MARIENLYST" data-away-team="BRONDBY" data-league-sort="43" data-correction="2" data-matchday="2018-11-22" data-game-status="2 HF" data-league-code="44878" data-league-name="FA CUP" data-country-name="DENMARK" data-league-round="4R" data-league-short="4R" data-home-id="38013" data-away-id="11911" data-ftr="false">
<div class="score_info score_cell">
<div id="ko_time" class="score_ko score_cell">23:30</div>

<div class="score-status score-cell live_ko_second">2 HF</div>

</div>
<div class="score_status score_cell">

<div id="match_status" class="score_time score_cell status-live status-live">58'</div>

</div>

<div class="score_league score_cell">
<div id="flag_iframe" class="score_league_flag score_cell" iframe="0"><span class="tooltip_flag">SHOW GAMES FROM DENMARK</span><a href="javascript:;"><img class="f" alt="DENMARK - FA CUP" src="https://newmedia.xscores.com/fpng/denmark.png"></a></div>
<div class="score_league_txt score_cell"><a href="javascript:;" class="league">4R</a></div>
</div>
<div class="score_teams  score_cell">
<div class="score_home score_cell">
<div class="score_home_txt score_cell wrap">

MARIENLYST
</div>
<div class="pull-right soccer_height">
<div class="lp"></div>

<div class="y_cards">&nbsp;</div>
<div class="r_cards">&nbsp;</div>

</div>
</div>
<div class="score_away score_cell">
<div class="score_away_txt score_cell wrap"><b>
BRONDBY
</b></div>
<div class="pull-right soccer_height">
<div class="lp">&nbsp;</div>

<div class="y_cards">&nbsp;</div>
<div class="r_cards">&nbsp;</div>

</div>
</div>
</div>

<div class="score_ht score_cell centerTXT">

<div class="scoreh_ht score_cell centerTXT">1</div>
<div class="scorea_ht score_cell centerTXT">3</div>
</div>

<div class="score_score score_cell centerTXT">
<div class="scoreh_ft score_cell centerTXT">1</div>
<div class="scorea_ft score_cell centerTXT">3</div>
</div>

<div class="score_et score_cell"></div>

<div class="score_pen score_cell"></div>


<div class="score_tv score_cell centerTXT"><i class="fa fa-television fa-proper-size tv_icn icon-blue" aria-hidden="true"></i></div>



<div class="score_info_img"><i class="fa fa-info fa-proper-size icon-blue" aria-hidden="true"></i></div>

<div class="score_fav score_cell centerTXT chooseFav"><a class="favoritesBtn" data-game-id="1631587" href="javascript:;"><i class="fa fa-star fa-proper-size icon-grey" aria-hidden="true"></i></a></div>


<div class="score_audio score_cell centerTXT"><a class="seperateAudioBtn" data-game-id="1631587" href="javascript:;"><i class="fa fa-volume-off icon-grey fa-sound-size" aria-hidden="true"></i></a></div>
<div class="odds_placeholder ">

<div class="odds"><p class="odd_price " title=""><a target="_blank" href=""></a></p><p class="odd_price " title=""><a target="_blank" href=""></a></p><p class="odd_price " title=""><a target="_blank" href=""></a></p></div></div>

<div class="score_remove score_cell centerTXT"><a class="removeGame" data-game-id="1631587" href="javascript:;"><i class="fa fa-times fa-delete-size icon-red" aria-hidden="true"></i></a></div>

</div>

0 个答案:

没有答案