paypal: Add function to download the CSV history

This commit is contained in:
Laurent Bachelier 2013-02-05 11:19:23 +01:00
commit efbc3b9ef6
2 changed files with 27 additions and 1 deletions

View file

@ -19,7 +19,7 @@
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from .pages import LoginPage, AccountPage
from .pages import LoginPage, AccountPage, DownloadHistoryPage
__all__ = ['Paypal']
@ -34,6 +34,7 @@ class Paypal(BaseBrowser):
'/cgi-bin/\?cmd=_login-run$': LoginPage,
'/cgi-bin/\?cmd=_login-submit.+$': LoginPage, # wrong login
'/cgi-bin/webscr\?cmd=_account&nav=0.0$': AccountPage,
'/cgi-bin/webscr\?cmd=_history-download&nav=0.3.1$': DownloadHistoryPage,
}
def home(self):
@ -70,5 +71,10 @@ class Paypal(BaseBrowser):
def get_history(self, account):
raise NotImplementedError()
def download_history(self):
self.location('/en/cgi-bin/webscr?cmd=_history-download&nav=0.3.1')
assert self.is_on_page(DownloadHistoryPage)
self.page.download()
def transfer(self, from_id, to_id, amount, reason=None):
raise NotImplementedError()

View file

@ -19,6 +19,7 @@
from decimal import Decimal
import re
import datetime
from weboob.tools.browser import BasePage, BrokenPageError
from weboob.capabilities.bank import Account
@ -113,3 +114,22 @@ class AccountPage(BasePage):
accounts[account.id] = account
return accounts
class DownloadHistoryPage(BasePage):
def download(self):
today = datetime.date.today()
self.browser.select_form(name='form1')
# download an entire year
self.browser['to_c'] = str(today.year)
self.browser['to_a'] = str(today.month)
self.browser['to_b'] = str(today.day)
self.browser['from_c'] = str(today.year - 1)
self.browser['from_a'] = str(today.month)
self.browser['from_b'] = str(today.day)
# only "real" stuff, no cancelled payments
self.browser['custom_file_type'] = ['comma_completed']
self.browser['latest_completed_file_type'] = ['']
self.browser.submit()