From 581488037a584bf093c176cb5104cf74b53add1e Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Fri, 19 Aug 2016 23:02:07 +0200 Subject: [PATCH] Hello world --- .gitignore | 5 ++++ composer.json | 14 +++++++++++ library/Account.php | 60 +++++++++++++++++++++++++++++++++++++++++++++ library/Deal.php | 8 ++++++ library/Deals.php | 8 ++++++ 5 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 library/Account.php create mode 100644 library/Deal.php create mode 100644 library/Deals.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3727f3e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/composer.phar +/index.php +/composer.lock +/vendor/ +/.idea/ \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..214341d --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "name": "shikiryu/lbcreposter", + "description": "Repost deal in LBC", + "type": "project", + "require": { + "fabpot/goutte": "^3.1" + }, + "authors": [ + { + "name": "Shikiryu", + "email": "clement@desmidt.fr" + } + ] +} diff --git a/library/Account.php b/library/Account.php new file mode 100644 index 0000000..655896c --- /dev/null +++ b/library/Account.php @@ -0,0 +1,60 @@ +client = $client; + $this->login = $login; + $this->password = $password; + } + + public function isConnected() + { + if (!$this->is_connected) { + $crawler = $this->client->request('GET', self::HOME_URL); + $this->is_connected = $crawler->filter('.loggedOut')->count() == 0; + } + return $this->is_connected; + } + + public function connect() + { + if (!$this->isConnected()) { + $crawler = $this->client->request('GET', self::LOGIN_URL); + $form = $crawler->selectButton('Se connecter')->form(); + $crawler = $this->client->submit($form, ['st_username' => $this->login, 'st_passwd' => $this->password]); + $this->is_connected = $crawler->filter('.account_userinfo')->count() > 0; + } + return $this->is_connected; + } + + public function getDeals() + { + $crawler = $this->client->request('GET', self::ACCOUNT_URL); +// $deals = $crawler->filter('#dashboard .list .element')->each() + } +} \ No newline at end of file diff --git a/library/Deal.php b/library/Deal.php new file mode 100644 index 0000000..c6f6d68 --- /dev/null +++ b/library/Deal.php @@ -0,0 +1,8 @@ +