Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
a3a9a1f6cc |
16
.drone.yml
16
.drone.yml
@ -1,16 +0,0 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: install
|
||||
pull: if-not-exists
|
||||
image: composer
|
||||
commands:
|
||||
- cp .env.example .env
|
||||
- composer install --ignore-platform-reqs --prefer-dist
|
||||
- php artisan key:generate
|
||||
|
||||
- name: test
|
||||
image: php:7
|
||||
commands:
|
||||
- vendor/bin/phpunit --configuration phpunit.xml
|
97
README.md
97
README.md
@ -1,46 +1,85 @@
|
||||
# My Home collection ![language](https://img.shields.io/badge/language-laravel-blue.svg) ![issues](https://img.shields.io/github/issues-raw/Chouchen/Shikiryu_backup) ![ci](https://ci.canhelpme.com/build-status/image/7?branch=main&label=PHPCensor&style=flat-square)
|
||||
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
|
||||
|
||||
> Because I need to keep some house in mind
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
||||
</p>
|
||||
|
||||
App to save house sale ads
|
||||
## About Laravel
|
||||
|
||||
## :books: Table of Contents
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Installation](#package-installation)
|
||||
- [Usage](#rocket-usage)
|
||||
- [Support](#hammer_and_wrench-support)
|
||||
- [Contributing](#memo-contributing)
|
||||
- [License](#scroll-license)
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
## :package: Installation
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
### Requirements
|
||||
## Learning Laravel
|
||||
|
||||
* git
|
||||
* composer
|
||||
* yarn or npm
|
||||
* a database (SQLite, MySQL, …)
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
### Then install this script
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
```sh
|
||||
git clone https://git.shikiryu.com/Shikiryu/MyHomeCollection.git
|
||||
composer install
|
||||
yarn install
|
||||
```
|
||||
## Laravel Sponsors
|
||||
|
||||
## :rocket: Usage
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
Create an account, add an ad, use the app !
|
||||
### Premium Partners
|
||||
|
||||
## :hammer_and_wrench: Support
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
|
||||
Please [open an issue](https://git.shikiryu.com/Shikiryu/MyHomeCollection/issues/new) for support.
|
||||
### Community Sponsors
|
||||
|
||||
## :memo: Contributing
|
||||
<a href="https://op.gg"><img src="http://opgg-static.akamaized.net/icon/t.rectangle.png" width="150"></a>
|
||||
|
||||
Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/Chouchen/Shikiryu_Backupleonard-henriquez/readme-boilerplateleonard-henriquez/readme-boilerplate/compare/).
|
||||
- [UserInsights](https://userinsights.com)
|
||||
- [Fragrantica](https://www.fragrantica.com)
|
||||
- [SOFTonSOFA](https://softonsofa.com/)
|
||||
- [User10](https://user10.com)
|
||||
- [Soumettre.fr](https://soumettre.fr/)
|
||||
- [CodeBrisk](https://codebrisk.com)
|
||||
- [1Forge](https://1forge.com)
|
||||
- [TECPRESSO](https://tecpresso.co.jp/)
|
||||
- [Runtime Converter](http://runtimeconverter.com/)
|
||||
- [WebL'Agence](https://weblagence.com/)
|
||||
- [Invoice Ninja](https://www.invoiceninja.com)
|
||||
- [iMi digital](https://www.imi-digital.de/)
|
||||
- [Earthlink](https://www.earthlink.ro/)
|
||||
- [Steadfast Collective](https://steadfastcollective.com/)
|
||||
- [We Are The Robots Inc.](https://watr.mx/)
|
||||
- [Understand.io](https://www.understand.io/)
|
||||
- [Abdel Elrafa](https://abdelelrafa.com)
|
||||
- [Hyper Host](https://hyper.host)
|
||||
- [Appoly](https://www.appoly.co.uk)
|
||||
- [云软科技](http://www.yunruan.ltd/)
|
||||
|
||||
## :scroll: License
|
||||
## Contributing
|
||||
|
||||
[Creative Commons Attribution NonCommercial (CC-BY-NC)](https://tldrlegal.com/license/creative-commons-attribution-noncommercial-(cc-nc)) © [Chouchen](https://github.com/Chouchen/)
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Parser;
|
||||
use GuzzleHttp\Exception\InvalidArgumentException;
|
||||
use Illuminate\Console\Command;
|
||||
use function GuzzleHttp\json_encode;
|
||||
|
||||
class ParseLinkCommand extends Command
|
||||
{
|
||||
@ -41,11 +39,7 @@ class ParseLinkCommand extends Command
|
||||
public function handle()
|
||||
{
|
||||
$parser = Parser::factory($this->argument('url'));
|
||||
try {
|
||||
$this->info(json_encode($parser->parse(), true));
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$parser->parse();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class UnknownParser extends Exception
|
||||
{
|
||||
|
||||
}
|
@ -73,22 +73,20 @@ class Home extends Model implements Feedable
|
||||
{
|
||||
// Download images on creation
|
||||
static::created(static function ($home) {
|
||||
if (!empty($home->pictures)) {
|
||||
Artisan::call('app:downloadimage ' . $home->id);
|
||||
}
|
||||
Artisan::call('app:downloadimage ' . $home->id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toFeedItem(): FeedItem
|
||||
public function toFeedItem()
|
||||
{
|
||||
return FeedItem::create()
|
||||
->id($this->id)
|
||||
->title($this->title)
|
||||
->summary($this->excerpt())
|
||||
->authorName('Shikiryu')
|
||||
->author('Shikiryu')
|
||||
->updated($this->created_at)
|
||||
->link(\route('public.view', ['slug' => $this->slug]))
|
||||
;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Exceptions\UnknownParser;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
@ -27,7 +26,6 @@ abstract class Parser
|
||||
* @param string $url
|
||||
*
|
||||
* @return \App\Parser|null
|
||||
* @throws \App\Exceptions\UnknownParser
|
||||
*/
|
||||
public static function factory(string $url): ?Parser
|
||||
{
|
||||
@ -38,86 +36,11 @@ abstract class Parser
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnknownParser(sprintf(
|
||||
'Can\'t find an url in «%s» file with the following URL «%s». Please update the file accordingly.',
|
||||
'parser.php',
|
||||
$url
|
||||
));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \App\ParsedHome
|
||||
*/
|
||||
abstract public function parse(): ParsedHome;
|
||||
|
||||
|
||||
/**
|
||||
* @param int $score
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateDPE($score)
|
||||
{
|
||||
if (empty($score)) {
|
||||
return 'Inconnu';
|
||||
}
|
||||
if ($score <= 50) {
|
||||
return 'A';
|
||||
}
|
||||
if ($score >= 51 && $score <= 90) {
|
||||
return 'B';
|
||||
}
|
||||
if ($score >= 91 && $score <= 150) {
|
||||
return 'C';
|
||||
}
|
||||
if ($score >= 151 && $score <= 230) {
|
||||
return 'D';
|
||||
}
|
||||
if ($score >= 231 && $score <= 330) {
|
||||
return 'E';
|
||||
}
|
||||
if ($score >= 331 && $score <= 450) {
|
||||
return 'F';
|
||||
}
|
||||
if ($score > 450) {
|
||||
return 'G';
|
||||
}
|
||||
|
||||
return 'Inconnu';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $score
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateGES($score)
|
||||
{
|
||||
if (empty($score)) {
|
||||
return 'Inconnu';
|
||||
}
|
||||
if ($score <= 5) {
|
||||
return 'A';
|
||||
}
|
||||
if ($score >= 6 && $score <= 10) {
|
||||
return 'B';
|
||||
}
|
||||
if ($score >= 11 && $score <= 20) {
|
||||
return 'C';
|
||||
}
|
||||
if ($score >= 21 && $score <= 35) {
|
||||
return 'D';
|
||||
}
|
||||
if ($score >= 36 && $score <= 55) {
|
||||
return 'E';
|
||||
}
|
||||
if ($score >= 56 && $score <= 80) {
|
||||
return 'F';
|
||||
}
|
||||
if ($score > 80) {
|
||||
return 'G';
|
||||
}
|
||||
|
||||
return 'Inconnu';
|
||||
}
|
||||
}
|
||||
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Parser;
|
||||
|
||||
use App\ParsedHome;
|
||||
use App\Parser;
|
||||
use GuzzleHttp\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use function GuzzleHttp\json_decode;
|
||||
|
||||
/**
|
||||
* Class Orpi
|
||||
* @package App\Parser
|
||||
*/
|
||||
class Orpi extends Parser
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parse(): ParsedHome
|
||||
{
|
||||
$request = $this->client->get($this->url);
|
||||
$body = $request->getBody()->getContents();
|
||||
$crawler = new Crawler($body);
|
||||
$parsedHome = new ParsedHome();
|
||||
/**
|
||||
* Orpi ads can be parsed 2 ways :
|
||||
* * sometimes, a JSON is included in the page so it's just a reading/feeding object
|
||||
* * else, we must crawl the webpage…
|
||||
*/
|
||||
$data_estate = $crawler->filter('[data-estate]');
|
||||
if ($data_estate->count() > 0) {
|
||||
return $this->parseJSON($parsedHome, $crawler);
|
||||
}
|
||||
|
||||
return $this->parseHTML($parsedHome, $crawler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \App\ParsedHome $parsed_home
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $crawler
|
||||
*
|
||||
* @return \App\ParsedHome
|
||||
*/
|
||||
private function parseJSON(ParsedHome $parsed_home, Crawler $crawler)
|
||||
{
|
||||
$data_estate = $crawler->filter('[data-estate]');
|
||||
try {
|
||||
$json_data = json_decode($data_estate->attr('data-estate'), true);
|
||||
$parsed_home->price = $json_data['price'];
|
||||
$parsed_home->city = $json_data['city']['name'];
|
||||
$parsed_home->surface = $json_data['surface'];
|
||||
$parsed_home->garden_surface = $json_data['lotSurface'];
|
||||
$parsed_home->rooms = $json_data['nbRooms'];
|
||||
$parsed_home->description = $json_data['longAd'];
|
||||
$parsed_home->title = $json_data['seo']['metaTitle'];
|
||||
$parsed_home->map = ['lat' => $json_data['latitude'], 'lng' => $json_data['longitude']];
|
||||
$parsed_home->pictures = $json_data['imagesFull'];
|
||||
$parsed_home->energy = $this->calculateDPE($json_data['consumptionValue']);
|
||||
$parsed_home->ges = $this->calculateGES($json_data['emissionValue']);
|
||||
|
||||
return $parsed_home;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return $this->parseHTML($parsed_home, $crawler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \App\ParsedHome $parsed_home
|
||||
* @param \Symfony\Component\DomCrawler\Crawler $crawler
|
||||
*
|
||||
* @return \App\ParsedHome
|
||||
*/
|
||||
private function parseHTML(ParsedHome $parsed_home, Crawler $crawler)
|
||||
{
|
||||
$ad = $crawler->filter('article');
|
||||
$first_section = $ad->children()->first();
|
||||
$second_section = $ad->children()->eq(1);
|
||||
$third_section = $ad->children()->eq(2);
|
||||
$parsed_home->description = $second_section->filter('.o-container')->children()->eq(1)->text();
|
||||
$second_section->filter('.c-badge__text')->each(static function (Crawler $detail, $i) use (&$parsed_home) {
|
||||
$detail_text = $detail->text();
|
||||
if (mb_strpos($detail_text, 'Terrain') === 0) {
|
||||
$parsed_home->garden_surface = mb_substr($detail_text, 8, -2);
|
||||
}
|
||||
|
||||
if (mb_strpos($detail_text, 'pièces') !== false) {
|
||||
$parsed_home->rooms = (int)$detail_text;
|
||||
}
|
||||
});
|
||||
$h1 = $first_section->filter('h1');
|
||||
$parsed_home->title = $h1->children()->first()->text();
|
||||
$parsed_home->surface = (int)$h1->children()->eq(2)->text();
|
||||
$parsed_home->city = $h1->children()->eq(4)->text();
|
||||
$parsed_home->price = (int)str_replace(' ', '', $first_section->filter('.u-h1')->text());
|
||||
$third_section->filter('.c-dpe')->each(static function (Crawler $detail, $i) use (&$parsed_home) {
|
||||
$abbr = $detail->filter('abbr');
|
||||
if ($abbr->count() > 0) {
|
||||
if ($detail->attr('c-dpe--ges') !== null) {
|
||||
$parsed_home->ges = $abbr->text();
|
||||
} elseif ($detail) {
|
||||
$parsed_home->energy = $abbr->text();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$request = $this->client->get($this->url.'/photos/');
|
||||
$body = $request->getBody()->getContents();
|
||||
$crawler = new Crawler($body);
|
||||
$parsed_home->pictures = $crawler
|
||||
->filter('.u-cover')
|
||||
->each(static function (Crawler $node, $i) {
|
||||
if (strtolower($node->nodeName()) === 'img') {
|
||||
return $node->attr('src');
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return $parsed_home;
|
||||
}
|
||||
}
|
@ -18,18 +18,13 @@ class OuestFrance extends Parser
|
||||
$crawler = new Crawler($body);
|
||||
$parsedHome = new ParsedHome();
|
||||
$parsedHome->title = $crawler->filter('h1')->text();
|
||||
$details = $crawler->filter('#blocCaractAnn > ul > li');
|
||||
$price = $crawler->filter('#strongPrix');
|
||||
if (!$price instanceof Crawler) {
|
||||
$price = $details->eq(0)->filter('strong')->text();
|
||||
}
|
||||
$parsedHome->price = (int)str_replace(' ', '', $price->text());
|
||||
$parsedHome->price = (int)str_replace(' ', '', $crawler->filter('#strongPrix')->text());
|
||||
$parsedHome->description = $crawler->filter('#blockonDescriptif')->text();
|
||||
$details = $crawler->filter('#blocCaractAnn > ul > li');
|
||||
$parsedHome->surface = (int)str_replace(' ', '', $details->eq(2)->filter('strong')->text());
|
||||
$parsedHome->garden_surface = (int)str_replace(' ', '', $details->eq(3)->filter('strong')->text());
|
||||
$parsedHome->rooms = (int)str_replace(' ', '', $details->eq(4)->filter('strong')->text());
|
||||
$dpeCateg = $crawler->filter('#dpeCateg > strong');
|
||||
$parsedHome->energy = $dpeCateg->count() === 1 ? $dpeCateg->text() : '';
|
||||
$parsedHome->energy = $crawler->filter('#dpeCateg > strong')->text();
|
||||
// $parsedHome->city = ?
|
||||
// $parsedHome->map = ?
|
||||
$parsedHome->pictures = $crawler
|
||||
|
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Parser;
|
||||
|
||||
use App\ParsedHome;
|
||||
use App\Parser;
|
||||
use NumberFormatter;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class Safti extends Parser
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parse(): ParsedHome
|
||||
{
|
||||
$request = $this->client->get($this->url);
|
||||
$body = $request->getBody()->getContents();
|
||||
$crawler = new Crawler($body);
|
||||
$parsed_home = new ParsedHome();
|
||||
|
||||
$property_single = $crawler->filter('[data-testid="real-estate"]');
|
||||
|
||||
$number_formatter = new NumberFormatter('en', NumberFormatter::DECIMAL);
|
||||
$currency_formatter = new NumberFormatter('en', NumberFormatter::CURRENCY);
|
||||
$currency = 'EUR';
|
||||
|
||||
$parsed_home->title = $property_single->filter('h1')->text();
|
||||
$parsed_home->price = $currency_formatter
|
||||
->parseCurrency($property_single->filter('.property__price')->text(), $currency);
|
||||
$parsed_home->city = $property_single?->children()?->children('div')?->eq(0)?->filter('p.h4')?->text();
|
||||
$parsed_home->description = $crawler->filter('[data-testid="real-estate-annonce-single-description"]')->text();
|
||||
|
||||
$property__additionals = $crawler->filter('.property__additionals');
|
||||
$energies = $property__additionals->filter('.energetic-indicator');
|
||||
if ($energies->count() >= 1) {
|
||||
$parsed_home->energy = substr($energies->eq(0)->text(), 0, 1);
|
||||
}
|
||||
if ($energies->count() >= 2) {
|
||||
$parsed_home->ges = substr($energies->eq(1)->text(), 0, 1);
|
||||
}
|
||||
|
||||
$crawler
|
||||
->filter('.property__informations .mobile-extends > div .property__informations__element')
|
||||
->each(static function (Crawler $property____information, $i) use (&$parsed_home, $number_formatter) {
|
||||
$name = trim($property____information->filter('i')->text());
|
||||
$value = trim($property____information->filter('b')->text());
|
||||
switch ($name) {
|
||||
case 'Pièces :':
|
||||
$parsed_home->rooms = (int)$value;
|
||||
break;
|
||||
case 'Surface habitable :':
|
||||
$parsed_home->surface = $number_formatter->parse($value);
|
||||
break;
|
||||
case 'Terrain :':
|
||||
$parsed_home->garden_surface = $number_formatter->parse($value);
|
||||
break;
|
||||
default:
|
||||
// break;
|
||||
}
|
||||
});
|
||||
|
||||
$parsed_home->pictures = $crawler
|
||||
->filter('[data-testid="real-estate-mosaic-photo"]')
|
||||
->filter('img')
|
||||
->each(static function ($img) {
|
||||
return $img->attr('src');
|
||||
});
|
||||
|
||||
return $parsed_home;
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@ namespace App\Parser;
|
||||
|
||||
use App\ParsedHome;
|
||||
use App\Parser;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
/**
|
||||
* Thanks to https://github.com/axeleroy/untoitpourcaramel/issues/3
|
||||
@ -27,19 +25,15 @@ class SeLoger extends Parser
|
||||
$token = $this->retrieveToken();
|
||||
$idAnnonce = $this->getIdAnnonceFromUrl($this->url);
|
||||
$url = sprintf('%s%s', self::LISTING_URL, $idAnnonce);
|
||||
try {
|
||||
$request = $this->client->request(
|
||||
'GET',
|
||||
$url,
|
||||
[
|
||||
'headers' => [
|
||||
'AppToken' => $token,
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (GuzzleException $e) {
|
||||
return $this->parseHTML();
|
||||
}
|
||||
$request = $this->client->request(
|
||||
'GET',
|
||||
$url,
|
||||
[
|
||||
'headers' => [
|
||||
'AppToken' => $token,
|
||||
],
|
||||
]
|
||||
);
|
||||
$annonce = json_decode($request->getBody()->getContents(), true);
|
||||
|
||||
$parsedHome = new ParsedHome();
|
||||
@ -89,61 +83,4 @@ class SeLoger extends Parser
|
||||
|
||||
return trim($request->getBody()->getContents(), '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \App\ParsedHome
|
||||
*/
|
||||
private function parseHTML()
|
||||
{
|
||||
$request = $this->client->get(
|
||||
$this->url,
|
||||
[
|
||||
'headers' => [
|
||||
'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0',
|
||||
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Accept-Encoding' => 'gzip, deflate, br',
|
||||
'Accept-Language' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||
'Cache-Control' => 'no-cache',
|
||||
'Connection' => 'keep-alive',
|
||||
]
|
||||
]
|
||||
);
|
||||
$body = $request->getBody()->getContents();
|
||||
$crawler = new Crawler($body);
|
||||
|
||||
$parsed_home = new ParsedHome();
|
||||
|
||||
$parsed_home->title = $crawler->filter('h1')->text();
|
||||
$parsed_home->description = $crawler->filter('#showcase-description > div')->first()->text();
|
||||
$parsed_home->price = (int) str_replace(' ', '', $crawler->filter('[class^=Summarystyled__PriceText]')->text());
|
||||
$parsed_home->city = $crawler->filter('[class^=Summarystyled__Address]')->text();
|
||||
$parsed_home->energy = $this->calculateDPE(
|
||||
(int)$crawler->filter('[class^=Preview__PreviewTooltipValue]')->first()->text()
|
||||
);
|
||||
$parsed_home->ges = $this->calculateGES(
|
||||
(int)$crawler->filter('[class^=Preview__PreviewTooltipValue]')->eq(1)->text()
|
||||
);
|
||||
|
||||
$crawler
|
||||
->filter('[class^=Summarystyled__TagsWrapper] > div')
|
||||
->each(static function (Crawler $property____information, $i) use (&$parsed_home) {
|
||||
$element = $property____information->children()->eq(1)->text();
|
||||
if ('pièces' === mb_substr($element, -6)) {
|
||||
$parsed_home->rooms = (int) $element;
|
||||
}
|
||||
if ('m²' === mb_substr($element, -2) && strpos($element, '/') === false) {
|
||||
$parsed_home->surface = (int) $element;
|
||||
}
|
||||
});
|
||||
|
||||
$parsed_home->pictures = $crawler
|
||||
->filter('.swiper-wrapper')
|
||||
->first()
|
||||
->filter('[data-background]')
|
||||
->each(static function ($img) {
|
||||
return $img->attr('data-background');
|
||||
});
|
||||
|
||||
return $parsed_home;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -34,5 +35,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
}
|
||||
return sprintf('%s m²', number_format($surface, 0, ',', ' '));
|
||||
});
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"php": "^7.3.0",
|
||||
"ext-json": "*",
|
||||
"artesaos/seotools": "^1.0",
|
||||
"absmoca/leboncoin": "dev-master",
|
||||
"artesaos/seotools": "^0",
|
||||
"emanueleminotto/simple-html-dom": "^1.5",
|
||||
"fabpot/goutte": "^4.0",
|
||||
"fideloper/proxy": "^4.2",
|
||||
@ -20,9 +20,8 @@
|
||||
"laravel/framework": "^8.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
"laravel/ui": "^3.0",
|
||||
"spatie/laravel-feed": "^4.0",
|
||||
"spatie/laravel-query-builder": "^4.0",
|
||||
"ext-intl": "*"
|
||||
"spatie/laravel-feed": "^2.7",
|
||||
"spatie/laravel-query-builder": "^2.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^2.3.6",
|
||||
@ -43,7 +42,9 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
},
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
|
4070
composer.lock
generated
4070
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -22,18 +22,6 @@ return [
|
||||
'description' => 'La sélection',
|
||||
'language' => 'fr-FR',
|
||||
|
||||
/*
|
||||
* The image to display for the feed. For Atom feeds, this is displayed as
|
||||
* a banner/logo; for RSS and JSON feeds, it's displayed as an icon.
|
||||
* An empty value omits the image attribute from the feed.
|
||||
*/
|
||||
'image' => '',
|
||||
|
||||
/*
|
||||
* The format of the feed. Acceptable values are 'rss', 'atom', or 'json'.
|
||||
*/
|
||||
'format' => 'atom',
|
||||
|
||||
/*
|
||||
* The view that will render the feed.
|
||||
*/
|
||||
@ -43,12 +31,6 @@ return [
|
||||
* The type to be used in the <link> tag
|
||||
*/
|
||||
'type' => 'application/atom+xml',
|
||||
|
||||
/*
|
||||
* The content type for the feed response. Set to an empty string to automatically
|
||||
* determine the correct value.
|
||||
*/
|
||||
'contentType' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -3,10 +3,8 @@
|
||||
use App\Parser\ImmobilierNotaires;
|
||||
use App\Parser\LannionImmo;
|
||||
use App\Parser\LBC;
|
||||
use App\Parser\Orpi;
|
||||
use App\Parser\OuestFrance;
|
||||
use App\Parser\Pap;
|
||||
use App\Parser\Safti;
|
||||
use App\Parser\SeLoger;
|
||||
|
||||
return [
|
||||
@ -16,8 +14,6 @@ return [
|
||||
'pap.fr' => Pap::class,
|
||||
'ouestfrance-immo.com' => OuestFrance::class,
|
||||
'lannion.immo' => LannionImmo::class,
|
||||
'immobilier.notaires.fr'=> ImmobilierNotaires::class,
|
||||
'orpi.com' => Orpi::class,
|
||||
'safti.fr' => Safti::class,
|
||||
'immobilier.notaires.fr'=> ImmobilierNotaires::class
|
||||
],
|
||||
];
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\User;
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateFailedJobsLaravel8 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->string('uuid')->after('id')->nullable()->unique();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('failed_jobs', static function (Blueprint $table) {
|
||||
$table->dropColumn('uuid');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
@ -9,6 +9,10 @@
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require __DIR__.'/../storage/framework/maintenance.php';
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|
21
tests/Feature/ExampleTest.php
Normal file
21
tests/Feature/ExampleTest.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
18
tests/Unit/ExampleTest.php
Normal file
18
tests/Unit/ExampleTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user