From 9fa7cb75713ae4bbf0989000494b933cf9c02049 Mon Sep 17 00:00:00 2001 From: nicofrand Date: Sat, 5 Oct 2019 13:42:12 +0200 Subject: [PATCH] [paypal] Fix accounts list retrieval --- modules/paypal/browser.py | 1 + modules/paypal/pages.py | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/paypal/browser.py b/modules/paypal/browser.py index d3ff7ac6df..397df67d6f 100644 --- a/modules/paypal/browser.py +++ b/modules/paypal/browser.py @@ -65,6 +65,7 @@ class Paypal(LoginBrowser): promo = URL('https://www.paypal.com/fr/webapps/mpp/clickthru/paypal-app-promo-2.*', '/fr/webapps/mpp/clickthru.*', PromoPage) account = URL('https://www.paypal.com/businessexp/money', + 'https://www.paypal.com/myaccount/money', 'https://www.paypal.com/webapps/business/money', AccountPage) pro_history = URL('https://\w+.paypal.com/businessexp/transactions/activity\?.*', ProHistoryPage) diff --git a/modules/paypal/pages.py b/modules/paypal/pages.py index a2604b7bef..4f520b83b7 100644 --- a/modules/paypal/pages.py +++ b/modules/paypal/pages.py @@ -24,7 +24,7 @@ from weboob.tools.compat import unicode from weboob.capabilities.bank import Account -from weboob.capabilities.base import NotAvailable, Currency +from weboob.capabilities.base import NotAvailable from weboob.exceptions import BrowserUnavailable, ActionNeeded from weboob.browser.exceptions import ServerError from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage @@ -169,22 +169,18 @@ def get_account(self, _id): def get_accounts(self): accounts = {} - content = self.doc.xpath('//div[@id="moneyPage" or @id="MoneyPage"]')[0] + content = self.doc.xpath('//section[@id="contents"]')[0] # Multiple accounts - lines = content.xpath('(//div[@class="col-md-8 multi-currency"])[1]/ul/li') + lines = content.xpath('.//ul[@class="multiCurrency-container"][1]/li') for li in lines: account = Account() account.iban = NotAvailable account.type = Account.TYPE_CHECKING - currency_code = CleanText().filter((li.xpath('./span[@class="currencyUnit"]/span') or li.xpath('./span[1]'))[0]) - currency = Currency.get_currency(currency_code) - if not currency: - self.logger.warning('Unable to find currency %r', currency_code) - continue + currency = CleanText().filter(li.xpath('.//span[contains(@class, "multiCurrency-label_alignMiddle")]')[0]) account.id = currency account.currency = currency - account.balance = CleanDecimal(replace_dots=True).filter(li.xpath('./span[@class="amount"]/text()')) + account.balance = CleanDecimal(replace_dots=True).filter(li.xpath('.//span[contains(@class, "multiCurrency-label_right")]/text()')[0]) account.label = u'%s %s*' % (self.browser.username, account.currency) accounts[account.id] = account self.browser.account_currencies.append(account.currency) -- GitLab