support CB operations (coming and history)

This commit is contained in:
Romain Bignon 2012-06-23 21:31:41 +02:00
commit f72d705204
3 changed files with 129 additions and 35 deletions

View file

@ -18,9 +18,12 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from urlparse import urlsplit, parse_qsl
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from .pages import SkipPage, LoginPage, AccountsPage, AccountHistoryPage
from .pages import SkipPage, LoginPage, AccountsPage, AccountHistoryPage, \
CBListPage, CBHistoryPage
__all__ = ['LCLBrowser']
@ -34,8 +37,11 @@ class LCLBrowser(BaseBrowser):
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
PAGES = {
'https://particuliers.secure.lcl.fr/outil/UAUT/Authentication/authenticate': LoginPage,
'https://particuliers.secure.lcl.fr/outil/UAUT\?from=.*': LoginPage,
'https://particuliers.secure.lcl.fr/outil/UWSP/Synthese': AccountsPage,
'https://particuliers.secure.lcl.fr/outil/UWLM/ListeMouvements.*/accesListeMouvements.*': AccountHistoryPage,
'https://particuliers.secure.lcl.fr/outil/UWCB/UWCBEncours.*/listeCBCompte.*': CBListPage,
'https://particuliers.secure.lcl.fr/outil/UWCB/UWCBEncours.*/listeOperations.*': CBHistoryPage,
'https://particuliers.secure.lcl.fr/outil/UAUT/Contrat/selectionnerContrat.*': SkipPage,
'https://particuliers.secure.lcl.fr/index.html': SkipPage
}
@ -69,7 +75,7 @@ class LCLBrowser(BaseBrowser):
def get_accounts_list(self):
if not self.is_on_page(AccountsPage):
self.login()
self.location('https://particuliers.secure.lcl.fr/outil/UWSP/Synthese')
return self.page.get_list()
def get_account(self, id):
@ -82,11 +88,32 @@ class LCLBrowser(BaseBrowser):
return None
def get_history(self,account):
self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account._link_id))
return self.page.get_operations(account)
def get_history(self, account):
self.location(account._link_id)
for tr in self.page.get_operations():
yield tr
#def get_coming_operations(self, account):
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
# self.location('/NS_AVEEC?ch4=%s' % account._link_id)
# return self.page.get_operations()
for tr in self.get_cb_operations(account, 1):
yield tr
def get_cb_operations(self, account, month=0):
"""
Get CB operations.
* month=0 : current operations (non debited)
* month=1 : previous month operations (debited)
"""
for link in account._coming_links:
v = urlsplit(self.absurl(link))
args = dict(parse_qsl(v.query))
args['MOIS'] = month
self.location(self.buildurl(v.path, **args))
for tr in self.page.get_operations():
yield tr
for card_link in self.page.get_cards():
self.location(card_link)
for tr in self.page.get_operations():
yield tr