如何只抓取活动div

时间:2018-06-19 17:26:18

标签: html css ruby nokogiri

我正在尝试抓取页面,并且想要获取未隐藏的div ...我正在使用nokogiri进行抓取。

status = doc.css('.fi-mu__m').map {|status| status.css('.fi-mu__score-info').css('.fi-s__status--abbr').css('.period .full_time').map(&:text)}

除了.period.full_time之外,我还需要其他东西

这是DOM部分的副本:

<div class="fi-s__status--abbr">

      <span class="period cancelled hidden">

    Annulé
      </span>
      <span class="period lineups hidden">

    Comp.
      </span>
      <span class="period half_time hidden">

    MT
      </span>
      <span class="period extra_time hidden">

    Fin 2ème MT
      </span>
      <span class="period extra_half_time hidden">

    End 1H ET
      </span>
      <span class="period penalty_shootout hidden">

    TAB
      </span>
      <span class="period full_time">

    Fin
      </span>
      <span class="period post_match  hidden">

    Fin
      </span>
      <span class="period minute hidden">0'</span>

            </div>

1 个答案:

答案 0 :(得分:1)

尝试.css('.period .full_time:not(.hidden)')

请参见:not operator