Skip to content

Instantly share code, notes, and snippets.

@lasselehtinen
Created December 3, 2015 14:42
Show Gist options
  • Save lasselehtinen/b754fffe3354132004c3 to your computer and use it in GitHub Desktop.
Save lasselehtinen/b754fffe3354132004c3 to your computer and use it in GitHub Desktop.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Goutte\Client;
class TestGoutte extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sample:command';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// Go to the symfony.com website
$client = new Client();
$crawler = $client->request('GET', 'http://www.symfony.com/blog/');
// Get the latest post in this category and display the titles
$crawler->filter('h2 > a')->each(function ($node) {
print $node->text()."\n";
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment