-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added WheeMove provider * Update readme.md Added provider to the list * Linted files * Update app/Importers/WheeMoveDataImporter.php Co-authored-by: vojcc <[email protected]> * Update WheeMoveDataImporter.php * Re added config/telescope.php --------- Co-authored-by: vojcc <[email protected]>
- Loading branch information
1 parent
fb2b2ed
commit b0e89b9
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Importers; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Symfony\Component\DomCrawler\Crawler; | ||
|
||
class WheeMoveDataImporter extends DataImporter | ||
{ | ||
private const COUNTRY_NAME = "Spain"; | ||
|
||
protected Crawler $sections; | ||
|
||
public function extract(): static | ||
{ | ||
try { | ||
$response = $this->client->get("https://www.wheemove.com/"); | ||
$html = $response->getBody()->getContents(); | ||
} catch (GuzzleException) { | ||
$this->createImportInfoDetails("400", self::getProviderName()); | ||
$this->stopExecution = true; | ||
} | ||
|
||
$crawler = new Crawler($html); | ||
|
||
$this->sections = $crawler->filter('section[data-id="4b8f82b"], section[data-id="59def84"]'); | ||
|
||
if (count($this->sections) === 0) { | ||
$this->createImportInfoDetails("204", self::getProviderName()); | ||
|
||
$this->stopExecution = true; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
public function transform(): void | ||
{ | ||
$existingCityProviders = []; | ||
|
||
if ($this->stopExecution) { | ||
return; | ||
} | ||
$cityNames = []; | ||
|
||
$firstSectionNames = $this->sections->first()->filter('span[class="elementor-icon-list-text"]'); | ||
$lastSectionNames = $this->sections->last()->filter('span[class="elementor-icon-list-text"]'); | ||
|
||
foreach ([$firstSectionNames, $lastSectionNames] as $sectionNames) { | ||
foreach ($sectionNames as $name) { | ||
$cityNames[] = $name->nodeValue; | ||
} | ||
} | ||
|
||
foreach ($cityNames as $name) { | ||
$provider = $this->load($name, self::COUNTRY_NAME); | ||
|
||
if ($provider !== "") { | ||
$existingCityProviders[] = $provider; | ||
} | ||
} | ||
|
||
$this->deleteMissingProviders(self::getProviderName(), $existingCityProviders); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Importers\WheeMoveDataImporter; | ||
|
||
class WheeMoveDataImporterJob extends DataImporterJob | ||
{ | ||
public function handle(WheeMoveDataImporter $importer): void | ||
{ | ||
$importer->setImportInfo($this->importInfoId)->extract()->transform(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
1. Urent | ||
1. Veo | ||
1. Voi | ||
1. WheeMove | ||
1. Zwings | ||
|
||
### Local development | ||
|