adding support for leroy merlin
This commit is contained in:
parent
158efcded0
commit
b9c8108d04
3 changed files with 42 additions and 14 deletions
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.bank import ICapBank
|
||||
from weboob.capabilities.bank import ICapBank, AccountNotFound
|
||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||
from weboob.tools.value import ValueBackendPassword
|
||||
|
||||
|
|
@ -46,10 +46,16 @@ class BanqueAccordBackend(BaseBackend, ICapBank):
|
|||
|
||||
def iter_accounts(self):
|
||||
with self.browser:
|
||||
return [self.browser.get_account()]
|
||||
return self.browser.get_accounts_list()
|
||||
|
||||
def get_account(self, id):
|
||||
return self.browser.get_account()
|
||||
def get_account(self, _id):
|
||||
with self.browser:
|
||||
account = self.browser.get_account(_id)
|
||||
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
raise AccountNotFound()
|
||||
|
||||
def iter_history(self, account):
|
||||
with self.browser:
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import urllib
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from weboob.capabilities.bank import Account
|
||||
|
||||
from .pages import LoginPage, IndexPage, AccountsPage, OperationsPage
|
||||
|
||||
|
|
@ -67,21 +68,32 @@ class BanqueAccordBrowser(BaseBrowser):
|
|||
if not self.is_logged():
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
def get_accounts_list(self):
|
||||
if not self.is_on_page(IndexPage):
|
||||
self.location('https://www.banque-accord.fr/site/s/detailcompte/detailcompte.html')
|
||||
|
||||
def get_account(self):
|
||||
for a in self.page.get_list():
|
||||
post = {'numeroCompte': a.id,}
|
||||
self.location('/site/s/detailcompte/detailcompte.html', urllib.urlencode(post))
|
||||
self.location('/site/s/detailcompte/ongletdetailcompte.html')
|
||||
a.balance = self.page.get_balance()
|
||||
yield a
|
||||
|
||||
|
||||
|
||||
def get_account(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
if not self.is_on_page(IndexPage):
|
||||
self.home()
|
||||
|
||||
account = Account()
|
||||
account.id = '0'
|
||||
account.label = self.page.get_card_name()
|
||||
|
||||
self.location('/site/s/detailcompte/ongletdetailcompte.html')
|
||||
account.balance = self.page.get_balance()
|
||||
|
||||
return account
|
||||
for a in self.get_accounts_list():
|
||||
if a.id == id:
|
||||
return a
|
||||
return None
|
||||
|
||||
def iter_history(self, account):
|
||||
post = {'numeroCompte': account.id,}
|
||||
self.location('/site/s/detailcompte/detailcompte.html', urllib.urlencode(post))
|
||||
self.location('/site/s/detailcompte/ongletdernieresoperations.html')
|
||||
|
||||
assert self.is_on_page(OperationsPage)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
from decimal import Decimal
|
||||
import re
|
||||
|
||||
from weboob.capabilities.bank import Account
|
||||
from weboob.tools.browser import BasePage, BrokenPageError
|
||||
from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError
|
||||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||
|
|
@ -88,6 +89,15 @@ class LoginPage(BasePage):
|
|||
self.browser.location(self.browser.buildurl(form.attrib['action'], identifiant=login, code=code), no_login=True)
|
||||
|
||||
class IndexPage(BasePage):
|
||||
def get_list(self):
|
||||
for line in self.document.xpath('//li[@id="menu-n2-mesproduits"]//li//a'):
|
||||
if line.get('onclick') is None:
|
||||
continue
|
||||
account = Account()
|
||||
account.id = line.get('onclick').split("'")[1]
|
||||
account.label = self.parser.tocleanstring(line)
|
||||
yield account
|
||||
|
||||
def get_card_name(self):
|
||||
return self.parser.tocleanstring(self.document.xpath('//h1')[0])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue