Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 76 additions & 73 deletions app/Console/Commands/DownloadImageAirlinersNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,80 @@
use GuzzleHttp\Client;
use Illuminate\Console\Command;

class DownloadImageAirlinersNet extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'bizjets:downloadImageAirlinersNet {reg?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Download an image from airliners.net for a plane registration';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct() {
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
$reg = $this->argument('reg');

echo "command called to download :" . $reg . PHP_EOL;

$url = "http://www.airliners.net/search?registrationActual=" . $reg;
// echo $url;
$client = new Client([
'timeout' => 60.0,
]);
$response = $client->request('GET', $url);
$html = $response->getBody()->getContents();

$doc = new \DOMDocument();
$tidy_config = array(
'clean' => true,
'output-xhtml' => true,
'show-body-only' => false,
'wrap' => 0,
);
$tidy = tidy_parse_string($html, $tidy_config, 'UTF8');
$tidy->cleanRepair();

$html = $tidy->html();

libxml_use_internal_errors(true);
$doc->loadHTML(mb_convert_encoding($html, "UTF-8"));
libxml_clear_errors();

$xpath = new \DOMXpath($doc);

$src = $xpath->evaluate("string(//img[@class='lazy-load']/@src)");

if ($src) {
$imgSrc = $src;
$contents = file_get_contents($imgSrc);
$save_path = public_path() . "/planeImages/airlinersNet/" . $reg . ".jpg";
file_put_contents($save_path, $contents);

$operator = $xpath->evaluate('string(//div[@class="ps-v2-results-display-detail-no-wrapping"] )');

echo "AirlinerNet: " . $operator . PHP_EOL;
}
}
class DownloadImageAirlinersNet extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'bizjets:downloadImageAirlinersNet {reg?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Download an image from airliners.net for a plane registration';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$reg = $this->argument('reg');

echo 'command called to download :'.$reg.PHP_EOL;

$url = 'http://www.airliners.net/search?registrationActual='.$reg;
// echo $url;
$client = new Client([
'timeout' => 60.0,
]);
$response = $client->request('GET', $url);
$html = $response->getBody()->getContents();

$doc = new \DOMDocument();
$tidy_config = [
'clean' => true,
'output-xhtml' => true,
'show-body-only' => false,
'wrap' => 0,
];
$tidy = tidy_parse_string($html, $tidy_config, 'UTF8');
$tidy->cleanRepair();

$html = $tidy->html();

libxml_use_internal_errors(true);
$doc->loadHTML(mb_convert_encoding($html, 'UTF-8'));
libxml_clear_errors();

$xpath = new \DOMXpath($doc);

$src = $xpath->evaluate("string(//img[@class='lazy-load']/@src)");

if ($src) {
$imgSrc = $src;
$contents = file_get_contents($imgSrc);
$save_path = public_path().'/planeImages/airlinersNet/'.$reg.'.jpg';
file_put_contents($save_path, $contents);

$operator = $xpath->evaluate('string(//div[@class="ps-v2-results-display-detail-no-wrapping"] )');

echo 'AirlinerNet: '.$operator.PHP_EOL;
}
}
}
147 changes: 75 additions & 72 deletions app/Console/Commands/DownloadImageJetPhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,79 @@
use GuzzleHttp\Client;
use Illuminate\Console\Command;

class DownloadImageJetPhoto extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'bizjets:downloadImageJetPhoto {reg?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Download an image from jet photo for a plane registration';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct() {
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
$reg = $this->argument('reg');

sleep(5); // to delay each download to jetphotos - 429 too many requests!

echo "command called to download :" . $reg . PHP_EOL;

$url = "https://www.jetphotos.com/registration/" . $reg;
//echo $url;

$client = new Client([
'timeout' => 60.0,
]);
$response = $client->request('GET', $url);
$html = $response->getBody()->getContents();

$doc = new \DOMDocument();

$tidy = tidy_parse_string($html);
$tidy->cleanRepair();

$html = $tidy->html();

libxml_use_internal_errors(true);
$doc->loadHTML(mb_convert_encoding($html, "UTF-8"));
libxml_clear_errors();

$xpath = new \DOMXpath($doc);

// jetphotos

$src = $xpath->evaluate("string(//img[@class='result__photo']/@src)");
if ($src) {
$imgSrc = "https:" . $src;
$contents = file_get_contents($imgSrc);
$save_path = public_path() . "/planeImages/jetPhotos/" . $reg . ".jpg";
file_put_contents($save_path, $contents);

$alt = $xpath->evaluate("string(//img[@class='result__photo']/@alt)");
echo "jetphoto " . $alt;
echo PHP_EOL;
}
}
class DownloadImageJetPhoto extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'bizjets:downloadImageJetPhoto {reg?}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Download an image from jet photo for a plane registration';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$reg = $this->argument('reg');

sleep(5); // to delay each download to jetphotos - 429 too many requests!

echo 'command called to download :'.$reg.PHP_EOL;

$url = 'https://www.jetphotos.com/registration/'.$reg;
//echo $url;

$client = new Client([
'timeout' => 60.0,
]);
$response = $client->request('GET', $url);
$html = $response->getBody()->getContents();

$doc = new \DOMDocument();

$tidy = tidy_parse_string($html);
$tidy->cleanRepair();

$html = $tidy->html();

libxml_use_internal_errors(true);
$doc->loadHTML(mb_convert_encoding($html, 'UTF-8'));
libxml_clear_errors();

$xpath = new \DOMXpath($doc);

// jetphotos

$src = $xpath->evaluate("string(//img[@class='result__photo']/@src)");
if ($src) {
$imgSrc = 'https:'.$src;
$contents = file_get_contents($imgSrc);
$save_path = public_path().'/planeImages/jetPhotos/'.$reg.'.jpg';
file_put_contents($save_path, $contents);

$alt = $xpath->evaluate("string(//img[@class='result__photo']/@alt)");
echo 'jetphoto '.$alt;
echo PHP_EOL;
}
}
}
17 changes: 6 additions & 11 deletions app/Console/Commands/ImportDeletedAircraftToLive.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Console\Commands;

use Illuminate\Console\Command;
use DB;
use App\Countries;
use App\Planes;
use App\PlanesNew;
use App\Countries;
use DB;
use Illuminate\Console\Command;

class ImportDeletedAircraftToLive extends Command
{
Expand Down Expand Up @@ -41,7 +41,7 @@ public function __construct()
*/
public function handle()
{
$this->comment("STARTING " . time());
$this->comment('STARTING '.time());

// first loop - get the results from planes (the original list)

Expand All @@ -50,15 +50,10 @@ public function handle()
$planesNew = PlanesNew::select('type', 'conNumber')->where('type', '=', $row->type)->where('conNumber', '=', $row->conNumber)->first();

if (isset($planesNew)) {

} else {

echo "DELETED ". $row->reg . " ". $row->type ." " . $row->conNumber .PHP_EOL;

}
echo 'DELETED '.$row->reg.' '.$row->type.' '.$row->conNumber.PHP_EOL;
}

}
});

}
}
Loading