get maximum history
This commit is contained in:
parent
221f73d600
commit
4df089ee1b
2 changed files with 27 additions and 18 deletions
|
|
@ -22,9 +22,6 @@
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from .pages import LoginPage, AccountsList, AccountHistory, UpdateInfoPage
|
from .pages import LoginPage, AccountsList, AccountHistory, UpdateInfoPage
|
||||||
|
|
||||||
from datetime import date
|
|
||||||
from dateutil.relativedelta import relativedelta
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Boursorama']
|
__all__ = ['Boursorama']
|
||||||
|
|
||||||
|
|
@ -83,21 +80,17 @@ class Boursorama(BaseBrowser):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
self.location(account._link_id)
|
link = account._link_id
|
||||||
|
|
||||||
|
while link is not None:
|
||||||
|
self.location(link)
|
||||||
if not self.is_on_page(AccountHistory):
|
if not self.is_on_page(AccountHistory):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
operations = self.page.get_operations()
|
for tr in self.page.get_operations():
|
||||||
# load last month as well
|
yield tr
|
||||||
target = date.today() - relativedelta(months=1)
|
|
||||||
self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year)))
|
|
||||||
operations += self.page.get_operations()
|
|
||||||
# and the month before, just in case you're greedy
|
|
||||||
target = date.today() - relativedelta(months=2)
|
|
||||||
self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year)))
|
|
||||||
operations += self.page.get_operations()
|
|
||||||
|
|
||||||
return operations
|
link = self.page.get_next_url()
|
||||||
|
|
||||||
def transfer(self, from_id, to_id, amount, reason=None):
|
def transfer(self, from_id, to_id, amount, reason=None):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from urlparse import urlparse
|
||||||
from datetime import date
|
from datetime import date
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -79,3 +80,18 @@ class AccountHistory(BasePage):
|
||||||
|
|
||||||
def get_operations(self):
|
def get_operations(self):
|
||||||
return self.operations
|
return self.operations
|
||||||
|
|
||||||
|
def get_next_url(self):
|
||||||
|
items = self.document.getroot().cssselect('ul.mainmenu li')
|
||||||
|
|
||||||
|
current = False
|
||||||
|
for li in reversed(items):
|
||||||
|
if li.attrib.get('class', '') == 'selected':
|
||||||
|
current = True
|
||||||
|
elif current:
|
||||||
|
a = li.find('a')
|
||||||
|
if 'year' in a.attrib.get('href', ''):
|
||||||
|
url = urlparse(self.url)
|
||||||
|
return url.path + a.attrib['href']
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue