From 0008cf17f180d2f5339222ed0d9d585049576cb9 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 1 Jul 2014 12:10:17 +0200 Subject: [PATCH] order transactions by date to prevent LinearDateGuesser to be duped by the f*cking website --- modules/cragr/web/browser.py | 2 +- modules/cragr/web/pages.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/cragr/web/browser.py b/modules/cragr/web/browser.py index 39268658..0c537adf 100644 --- a/modules/cragr/web/browser.py +++ b/modules/cragr/web/browser.py @@ -175,7 +175,7 @@ class Cragr(BaseBrowser): for tr in self.page.get_history(date_guesser): yield tr else: - url = account._link + url = self.page.get_order_by_date_url() while url: self.location(url) diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index 22d98363..c795b74b 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -245,6 +245,13 @@ class TransactionsPage(BasePage): return None + def get_order_by_date_url(self): + try: + link = self.document.xpath('//table[@class="ca-table"]/thead//a[text()="Date"]')[0].attrib['href'] + except IndexError: + link = self.url + return link + COL_DATE = 0 COL_TEXT = 1 COL_DEBIT = None