blob: 06091bf023bc1e38ccfbbf15c2385ea57e181246 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 | <?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Goutte\Client;
class ScrapeUrl extends Command
{
    protected $signature = 'scrape:url { url }';
    protected $description = 'Scrape a webpage for data';
    public function handle()
    {
        $url = $this->argument('url');
        $crawler = (new Client())->request('GET', $this->argument('url'));
        $crawler->filter('title')->each(
            function ($node) {
                print $node->text()."\n";
            }
        );
    }
}
 |