PHP code example of rebelinblue / fluent-web-crawler

1. Go to this page and download the library: Download rebelinblue/fluent-web-crawler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rebelinblue / fluent-web-crawler example snippets


use REBELinBLUE\Crawler;

$crawler = new Crawler();

$crawler->visit('http://www.example.com');

$crawler->type('username', 'admin')
        ->type('password', 'password')
        ->press('Login');
        
// This can also be written as the following

$crawler->submitForm('Login', [
    'username' => 'admin',
    'password' => 'password',
]);


if ($crawler->dontSeeText('Hello World')) {
    throw new \Exception('The page does not contain the expected text');
}

use Goutte\Client as GoutteClient;
use GuzzleHttp\Client as GuzzleClient;
    
$goutteClient = new GoutteClient();
$guzzleClient = new GuzzleClient([
    'timeout' => 60,
]);
$goutteClient->setClient($guzzleClient);

$crawler = new Crawler($goutteClient);