Neue commands.
parent
42cc96a14a
commit
d2f1c82098
|
@ -29,10 +29,12 @@ class scrapeProperty extends Command
|
||||||
|
|
||||||
$seeds = Edomizil::getAllSeeds();
|
$seeds = Edomizil::getAllSeeds();
|
||||||
foreach($seeds as $seed){
|
foreach($seeds as $seed){
|
||||||
Edomizil::ScrapeProperty($seed);
|
$this->info('Scraping '.$seed);
|
||||||
|
$scraper = Edomizil::ScrapeProperty($seed);
|
||||||
|
$this->info($scraper.' properties were found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Scraping was successfull.');
|
$this->info('Finished scraping.');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class scrapePropertyDate extends Command
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'scrape:propertydata {propertyId?}';
|
protected $signature = 'scrape:propertydata {propertyId?} {--seed=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
|
@ -28,15 +28,23 @@ class scrapePropertyDate extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$propertyId = $this->argument('propertyId');
|
$propertyId = $this->argument('propertyId');
|
||||||
|
$seed = $this->option('seed');
|
||||||
|
|
||||||
if($propertyId && is_numeric($propertyId)){
|
if($seed){
|
||||||
$property = Property::select('id','property_platform_id')->where('id', 'like', $propertyId)->get();
|
|
||||||
}else{
|
$property = Property::select('id','property_platform_id')->where('seed_id', $seed)->inRandomOrder()->take(1)->get();
|
||||||
$property = Property::select('id','property_platform_id')->inRandomOrder()->take(1)->get();
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
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]);
|
$data = Edomizil::scrapePropertyData($property[0]);
|
||||||
$this->info('Scraping for property '.$property[0]->property_platform_id.' has ended.');
|
$this->info('Scraping for property '.$property[0]->property_platform_id.' has ended. Here is the result: '.$data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,9 @@ class Seed extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $table = 'seeds';
|
protected $table = 'seeds';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'region_id',
|
||||||
|
'uri'
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,13 +91,20 @@ class Edomizil{
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count($json['offers']);
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
self::saveHttpException($response,'property', $seed->id);
|
self::saveHttpException($response,'property', $seed->id);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function scrapePropertyData($property){
|
public static function scrapePropertyData($property){
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
// scrape offer details such as name etc.
|
// scrape offer details such as name etc.
|
||||||
$offer = Http::get('https://www.e-domizil.ch/rental/offer/'.$property->property_platform_id);
|
$offer = Http::get('https://www.e-domizil.ch/rental/offer/'.$property->property_platform_id);
|
||||||
|
|
||||||
|
@ -114,6 +121,8 @@ class Edomizil{
|
||||||
self::saveHttpException($offer,'offer',$property->id);
|
self::saveHttpException($offer,'offer',$property->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result['offer'] = $offer->body();
|
||||||
|
|
||||||
// scrape price of property
|
// scrape price of property
|
||||||
$price = Http::get('https://www.e-domizil.ch/booking/checkout/priceDetails/'.$property->property_platform_id);
|
$price = Http::get('https://www.e-domizil.ch/booking/checkout/priceDetails/'.$property->property_platform_id);
|
||||||
|
|
||||||
|
@ -130,6 +139,8 @@ class Edomizil{
|
||||||
self::saveHttpException($price,'price',$property->id);
|
self::saveHttpException($price,'price',$property->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result['price'] = $price->body();
|
||||||
|
|
||||||
// scrape calendar which contains occupancies
|
// scrape calendar which contains occupancies
|
||||||
$calendar = Http::get('https://www.e-domizil.ch/api/v2/calendar/'.$property->property_platform_id, [
|
$calendar = Http::get('https://www.e-domizil.ch/api/v2/calendar/'.$property->property_platform_id, [
|
||||||
'year' => date("Y"),
|
'year' => date("Y"),
|
||||||
|
@ -146,9 +157,13 @@ class Edomizil{
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
self::saveHttpException($calendar,'price',$property->id);
|
self::saveHttpException($calendar,'calendar',$property->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result['calendar'] = $calendar->body();
|
||||||
|
|
||||||
|
return json_encode($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
|
"filament/filament": "^3.2",
|
||||||
|
"filament/infolists": "^3.2",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"laravel/framework": "^10.10",
|
"laravel/framework": "^10.10",
|
||||||
"laravel/sanctum": "^3.3",
|
"laravel/sanctum": "^3.3",
|
||||||
|
@ -35,7 +37,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-autoload-dump": [
|
"post-autoload-dump": [
|
||||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
"@php artisan package:discover --ansi"
|
"@php artisan package:discover --ansi",
|
||||||
|
"@php artisan filament:upgrade"
|
||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -167,6 +167,7 @@ return [
|
||||||
App\Providers\AuthServiceProvider::class,
|
App\Providers\AuthServiceProvider::class,
|
||||||
// App\Providers\BroadcastServiceProvider::class,
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
|
App\Providers\Filament\AdminPanelProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
])->toArray(),
|
])->toArray(),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue