You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

3 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use Illuminate\Support\Facades\Http;
  6. use SimpleXMLElement;
  7. class CrawlerRunCommand extends Command
  8. {
  9. /**
  10. * The signature of the command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'crawler:run';
  15. /**
  16. * The description of the command.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. * Execute the console command.
  23. *
  24. * @return mixed
  25. */
  26. public function handle()
  27. {
  28. $sources = [
  29. 'https://steadyhq.com/rss/krautreporter?auth=f7da00aa-fd3f-4411-a16f-138a1ce88dcc',
  30. 'https://steadyhq.com/rss/insertmoin?auth=d37bffc9-9a84-4eed-95f6-3b6cb77c2406'
  31. ];
  32. $handler = new RssHandler();
  33. $response = $handler->get($url);
  34. // if it is a 200
  35. if ($response->ok()) {
  36. $handler->run($response, $actions);
  37. // if there is an error on the source
  38. } else if ($response->serverError()) {
  39. }
  40. }
  41. private function get($url, $handler)
  42. {
  43. }
  44. /**
  45. * Define the command's schedule.
  46. *
  47. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  48. * @return void
  49. *
  50. */
  51. public function schedule(Schedule $schedule): void
  52. {
  53. $schedule->command(static::class)->everyMinute();
  54. }
  55. }