mercredi 6 novembre 2019

How to get last child while parsing HTML with Goutte in Laravel

<div class="table">
        <div class="table-head">
            <div class="table-head-title">Ranking Equipos</div>
        </div>
        <div class="table-body">
            <div class="table-body-row active">
                <div class="col-key">Mark</div>
                <div class="col-value">9233</div>
            </div>
            <div class="table-body-row">
                <div class="col-key">Amanda</div>
                <div class="col-value">7216</div>
            </div>
            <div class="table-body-row">
                <div class="col-key">Mark</div>
                <div class="col-value">6825</div>
            </div>
            <div class="table-body-row">
                <div class="col-key">Paul</div>
                <div class="col-value">6184</div>
            </div>
            <div class="table-body-row">
                <div class="col-key">Amanda</div>
                <div class="col-value">5866</div>
            </div>
        </div>
    </div>

This is my HTML and I want to get last child of .table-body. I tried to use JavaScript like logic and used indexing like this $lastChild = $node->filter('.table-body .table-body-row')[4]; but it shows error. Cannot use object of type "Symfony\Component\DomCrawler\Crawler" as array



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire