FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

Populate Paginated Data on the Same page #353

Open JakeHenshall opened 6 years ago

JakeHenshall commented 6 years ago

Hi,

I Have the code below

$text = [];

$crawler->filter('#pagination-bottom .ui-pagination-navi a')->each(function ($node) use (&$text) {
    $text[] = $node->text();
    return $text;
});

foreach ($text as $texts) {
    echo '<a class="pagination" href="' . "https://www.site.com/af/" . $_POST['acme-message'] . ".html?SearchText=" . $_POST['acme-message'] . '&page=' . $texts . '">' . $texts . '</a>';
}

The acme-message is just from this input -> <input type="text" name="acme-message" value="" />

What I'm trying to do:

The Foreach link takes me to the actual site, I don't want that to happen.

I want it to pull the paginated data from the clicked pagination page link ie page 2. Then once clicked display the data from that clicked page and don't go to the site.

Hopefully, that makes sense.

Thanks, Jake.