PHP code example of gueroverde / goutte
1. Go to this page and download the library: Download gueroverde/goutte 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/ */
gueroverde / goutte example snippets
// config/app.php
return [
// ...
'providers' => [
// ...
/*
* Package Service Providers...
*/
Weidner\Goutte\GoutteServiceProvider::class, // [1]
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
// ...
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
// ...
'Goutte' => Weidner\Goutte\GoutteFacade::class, // [2]
'Hash' => Illuminate\Support\Facades\Hash::class,
// ...
],
];
// routes/web.php
Route::get('/', function() {
$crawler = Goutte::request('GET', 'https://duckduckgo.com/html/?q=Laravel');
$crawler->filter('.result__title .result__a')->each(function ($node) {
dump($node->text());
});
return view('welcome');
});
return [
'client' => [
'allow_redirects' => false,
'cookies' => true,
],
];
sh
php artisan vendor:publish --provider="Weidner\Goutte\GoutteServiceProvider"