summaryrefslogtreecommitdiff
path: root/app/Console/Commands/ScrapeUrl.php
diff options
context:
space:
mode:
authorFbenas <philbeansburton@gmail.com>2020-06-21 17:58:23 +0100
committerFbenas <philbeansburton@gmail.com>2020-06-21 17:58:23 +0100
commit9cd0234665ea66dff172d94b9c1b4cb61b1d25b1 (patch)
tree9cb5d13acbf3c5bb8c842620ceb8a104b41babb7 /app/Console/Commands/ScrapeUrl.php
parent8d6e8b306d7836e4075a13ad98617bfe5afaa1a0 (diff)
Improve robustness of all scripts and add more to sync commandHEADmaster
Diffstat (limited to 'app/Console/Commands/ScrapeUrl.php')
-rw-r--r--app/Console/Commands/ScrapeUrl.php40
1 files changed, 2 insertions, 38 deletions
diff --git a/app/Console/Commands/ScrapeUrl.php b/app/Console/Commands/ScrapeUrl.php
index c02080e..06091bf 100644
--- a/app/Console/Commands/ScrapeUrl.php
+++ b/app/Console/Commands/ScrapeUrl.php
@@ -7,55 +7,19 @@ use Goutte\Client;
class ScrapeUrl extends Command
{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
protected $signature = 'scrape:url { url }';
-
- /**
- * The console command description.
- *
- * @var string
- */
protected $description = 'Scrape a webpage for data';
- protected $client;
-
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- $this->client = new Client();
- }
-
- /**
- * Execute the console command.
- *
- * @return mixed
- */
public function handle()
{
$url = $this->argument('url');
- if ($url != 'https://www.sixnationsrugby.com/fixtures/') {
- $this->error('Url not supported');
- return;
- }
-
- $crawler = $this->client->request('GET', $this->argument('url'));
+ $crawler = (new Client())->request('GET', $this->argument('url'));
- $crawler->filter('div.fixtures__top-tier')->each(
+ $crawler->filter('title')->each(
function ($node) {
print $node->text()."\n";
}
);
-
-
}
}