diff --git a/scraper/app/Console/Commands/scrapeProperty.php b/scraper/app/Console/Commands/scrapeProperty.php index 2825cda..6443a4e 100644 --- a/scraper/app/Console/Commands/scrapeProperty.php +++ b/scraper/app/Console/Commands/scrapeProperty.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Scraper\Edomizil; use Illuminate\Console\Command; class scrapeProperty extends Command @@ -18,13 +19,20 @@ class scrapeProperty extends Command * * @var string */ - protected $description = 'Scrapes for properties from seed'; + protected $description = 'Scrapes for properties from seeds.'; /** * Execute the console command. */ public function handle() { - + + $seeds = Edomizil::getAllSeeds(); + foreach($seeds as $seed){ + Edomizil::ScrapeProperty($seed); + } + + $this->info('Scraping was successfull.'); + } } diff --git a/scraper/app/Console/Commands/scrapePropertyDate.php b/scraper/app/Console/Commands/scrapePropertyDate.php index 3a89a7f..b09155b 100644 --- a/scraper/app/Console/Commands/scrapePropertyDate.php +++ b/scraper/app/Console/Commands/scrapePropertyDate.php @@ -2,6 +2,8 @@ namespace App\Console\Commands; +use App\Scraper\Edomizil; +use App\Models\Property; use Illuminate\Console\Command; class scrapePropertyDate extends Command @@ -11,20 +13,30 @@ class scrapePropertyDate extends Command * * @var string */ - protected $signature = 'scrape:propertydata'; + protected $signature = 'scrape:propertydata {propertyId?}'; /** * The console command description. * * @var string */ - protected $description = 'Scrapes for property data from properties.'; + protected $description = 'Scrapes the data from one random property or property with ID from argument.'; /** * Execute the console command. */ public function handle() { - // + $propertyId = $this->argument('propertyId'); + + if($propertyId && is_numeric($propertyId)){ + $property = Property::select('id','property_platform_id')->where('id', 'like', $propertyId)->get(); + }else{ + $property = Property::select('id','property_platform_id')->inRandomOrder()->take(1)->get(); + } + + Edomizil::scrapePropertyData($property[0]); + $this->info('Scraping for property '.$property[0]->property_platform_id.' has ended.'); + } }