本文整理汇总了Python中weboob.capabilities.bank.Transfer.origin方法的典型用法代码示例。如果您正苦于以下问题:Python Transfer.origin方法的具体用法?Python Transfer.origin怎么用?Python Transfer.origin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.bank.Transfer
的用法示例。
在下文中一共展示了Transfer.origin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def transfer(self, account, to, amount, reason=None):
if self.is_new_website:
raise NotImplementedError()
# access the transfer page
self.transfert.go(subbank=self.currentSubBank)
# fill the form
form = self.page.get_form(xpath="//form[@id='P:F']")
try:
form['data_input_indiceCompteADebiter'] = self.page.get_from_account_index(account)
form['data_input_indiceCompteACrediter'] = self.page.get_to_account_index(to)
except ValueError as e:
raise TransferError(e.message)
form['[t:dbt%3adouble;]data_input_montant_value_0_'] = '%s' % str(amount).replace('.', ',')
if reason is not None:
form['[t:dbt%3astring;x(27)]data_input_libelleCompteDebite'] = reason
form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason
del form['_FID_GoCancel']
del form['_FID_DoValidate']
form['_FID_DoValidate.x'] = str(randint(3, 125))
form['_FID_DoValidate.y'] = str(randint(3, 22))
form.submit()
# look for known errors
content = self.page.get_unicode_content()
insufficient_amount_message = u'Le montant du virement doit être positif, veuillez le modifier'
maximum_allowed_balance_message = u'Montant maximum autorisé au débit pour ce compte'
if insufficient_amount_message in content:
raise TransferError('The amount you tried to transfer is too low.')
if maximum_allowed_balance_message in content:
raise TransferError('The maximum allowed balance for the target account has been / would be reached.')
# look for the known "all right" message
ready_for_transfer_message = u'Confirmer un virement entre vos comptes'
if ready_for_transfer_message not in content:
raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message)
# submit the confirmation form
form = self.page.get_form(xpath="//form[@id='P:F']")
del form['_FID_DoConfirm']
form['_FID_DoConfirm.x'] = str(randint(3, 125))
form['_FID_DoConfirm.y'] = str(randint(3, 22))
submit_date = datetime.now()
form.submit()
# look for the known "everything went well" message
content = self.page.get_unicode_content()
transfer_ok_message = u'Votre virement a été exécuté'
if transfer_ok_message not in content:
raise TransferError('The expected message "%s" was not found.' % transfer_ok_message)
# We now have to return a Transfer object
transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S'))
transfer.amount = amount
transfer.origin = account
transfer.recipient = to
transfer.date = submit_date
return transfer
示例2: recap
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def recap(self):
div = self.document.find('//div[@class="content recap"]')
transfer = Transfer(0)
transfer.amount = Decimal(FrenchTransaction.clean_amount(div.xpath('.//span[@id="confirmtransferAmount"]')[0].text))
transfer.origin = div.xpath('.//span[@id="confirmfromAccount"]')[0].text
transfer.recipient = div.xpath('.//span[@id="confirmtoAccount"]')[0].text
transfer.reason = div.xpath('.//span[@id="confirmtransferMotive"]')[0].text
return transfer
示例3: transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def transfer(self, account, to, amount, reason=None):
# access the transfer page
transfert_url = 'WI_VPLV_VirUniSaiCpt.asp?RAZ=ALL&Cat=6&PERM=N&CHX=A'
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, transfert_url))
# fill the form
self.select_form(name='FormVirUniSaiCpt')
self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None:
self['LIBDBT'] = reason
self['LIBCRT'] = reason
self.submit()
# look for known errors
content = unicode(self.response().get_data(), self.ENCODING)
insufficient_amount_message = u'Montant insuffisant.'
maximum_allowed_balance_message = u'Solde maximum autorisé dépassé.'
if content.find(insufficient_amount_message) != -1:
raise TransferError('The amount you tried to transfer is too low.')
if content.find(maximum_allowed_balance_message) != -1:
raise TransferError('The maximum allowed balance for the target account has been / would be reached.')
# look for the known "all right" message
ready_for_transfer_message = u'Confirmez un virement entre vos comptes'
if not content.find(ready_for_transfer_message):
raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message)
# submit the confirmation form
self.select_form(name='FormVirUniCnf')
submit_date = datetime.now()
self.submit()
# look for the known "everything went well" message
content = unicode(self.response().get_data(), self.ENCODING)
transfer_ok_message = u'Votre virement a été exécuté ce jour'
if not content.find(transfer_ok_message):
raise TransferError('The expected message "%s" was not found.' % transfer_ok_message)
# We now have to return a Transfer object
transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S'))
transfer.amount = amount
transfer.origin = account
transfer.recipient = to
transfer.date = submit_date
return transfer
示例4: transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def transfer(self, account, to, amount, reason=None):
# access the transfer page
parameters = 'RAZ=ALL&Cat=6&PERM=N&CHX=A'
page = self.transfert.go(subbank=self.currentSubBank, parameters=parameters)
# fill the form
form = self.page.get_form(name='FormVirUniSaiCpt')
form['IDB'] = account[-1]
form['ICR'] = to[-1]
form['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason is not None:
form['LIBDBT'] = reason
form['LIBCRT'] = reason
page = form.submit()
# look for known errors
content = page.response.text
insufficient_amount_message = u'Montant insuffisant.'
maximum_allowed_balance_message = u'Solde maximum autorisé dépassé.'
if insufficient_amount_message in content:
raise TransferError('The amount you tried to transfer is too low.')
if maximum_allowed_balance_message in content:
raise TransferError('The maximum allowed balance for the target account has been / would be reached.')
# look for the known "all right" message
ready_for_transfer_message = u'Confirmez un virement entre vos comptes'
if ready_for_transfer_message in content:
raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message)
# submit the confirmation form
form = page.get_form(name='FormVirUniCnf')
submit_date = datetime.now()
page = form.submit()
# look for the known "everything went well" message
content = page.response.text
transfer_ok_message = u'Votre virement a été exécuté ce jour'
if not transfer_ok_message in content:
raise TransferError('The expected message "%s" was not found.' % transfer_ok_message)
# We now have to return a Transfer object
transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S'))
transfer.amount = amount
transfer.origin = account
transfer.recipient = to
transfer.date = submit_date
return transfer
示例5: transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def transfer(self, from_id, to_id, amount, reason=None):
if not self.is_on_page(pages.TransferPage):
self.location('/NS_VIRDF')
self.page.transfer(from_id, to_id, amount, reason)
if not self.is_on_page(pages.TransferCompletePage):
raise TransferError('An error occured during transfer')
transfer = Transfer(self.page.get_id())
transfer.amount = amount
transfer.origin = from_id
transfer.recipient = to_id
transfer.date = datetime.now()
return transfer
示例6: recap
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def recap(self):
if len(self.document.xpath('//p[@class="alert alert-success"]')) == 0:
raise BrokenPageError('Unable to find confirmation')
div = self.document.find(
'//div[@class="encadre transfert-validation"]')
transfer = Transfer(0)
transfer.amount = Decimal(FrenchTransaction.clean_amount(
div.xpath('.//label[@id="confirmtransferAmount"]')[0].text))
transfer.origin = div.xpath(
'.//span[@id="confirmfromAccount"]')[0].text
transfer.recipient = div.xpath(
'.//span[@id="confirmtoAccount"]')[0].text
transfer.reason = unicode(
div.xpath('.//span[@id="confirmtransferMotive"]')[0].text)
return transfer
示例7: make_transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def make_transfer(self, from_account, to_account, amount):
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_aiguillage/init-saisieComptes.ea')
self.page.set_accouts(from_account, to_account)
#TODO: Check
self.page.complete_transfer(amount)
self.page.confirm()
id_transfer = self.page.get_transfer_id()
transfer = Transfer(id_transfer)
transfer.amount = amount
transfer.origin = from_account.label
transfer.recipient = to_account.label
transfer.date = datetime.now()
return transfer
示例8: transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def transfer(self, from_id, to_id, amount, reason=None):
if not self.is_on_page(TransferPage):
self.location('/NS_VIRDF')
# Need to clean HTML before parse it
html = self.response().get_data().replace("<!input", "<input")
response = mechanize.make_response(
html, [("Content-Type", "text/html")],
"https://client.hellobank.fr/NS_VIRDF", 200, "OK")
self.set_response(response)
accounts = self.page.get_accounts()
self.page.transfer(from_id, to_id, amount, reason)
if not self.is_on_page(TransferCompletePage):
raise TransferError('An error occured during transfer')
transfer = Transfer(self.page.get_id())
transfer.amount = amount
transfer.origin = accounts[from_id].label
transfer.recipient = accounts[to_id].label
transfer.date = datetime.now()
return transfer
示例9: do_transfer
# 需要导入模块: from weboob.capabilities.bank import Transfer [as 别名]
# 或者: from weboob.capabilities.bank.Transfer import origin [as 别名]
def do_transfer(self, account, to, amount, reason=None):
"""
Transfer the given amount of money from an account to another,
tagging the transfer with the given reason.
"""
# access the transfer page
transfer_page_unreachable_message = u'Could not reach the transfer page.'
self.home()
if not self.page.is_accounts_list():
raise TransferError(transfer_page_unreachable_message)
operations_url = self.page.operations_page_url()
self.location('https://%s%s' % (self.DOMAIN, operations_url))
transfer_url = self.page.transfer_page_url()
abs_transfer_url = 'https://%s%s' % (self.DOMAIN, transfer_url)
self.location(abs_transfer_url)
if not self.page.is_transfer_page():
raise TransferError(transfer_page_unreachable_message)
source_accounts = self.page.get_transfer_source_accounts()
target_accounts = self.page.get_transfer_target_accounts()
# check that the given source account can be used
if not account in source_accounts.values():
raise TransferError('You cannot use account %s as a source account.' % account)
# check that the given source account can be used
if not to in target_accounts.values():
raise TransferError('You cannot use account %s as a target account.' % to)
# separate euros from cents
amount_euros = int(amount)
amount_cents = int((amount * 100) - (amount_euros * 100))
# let's circumvent https://github.com/jjlee/mechanize/issues/closed#issue/17
# using http://wwwsearch.sourceforge.net/mechanize/faq.html#usage
adjusted_response = self.response().get_data().replace('<br/>', '<br />')
response = mechanize.make_response(adjusted_response, [('Content-Type', 'text/html')], abs_transfer_url, 200, 'OK')
self.set_response(response)
# fill the form
self.select_form(nr=0)
self['numCompteEmetteur'] = ['%s' % self.dict_find_value(source_accounts, account)]
self['numCompteBeneficiaire'] = ['%s' % self.dict_find_value(target_accounts, to)]
self['montantPartieEntiere'] = '%s' % amount_euros
self['montantPartieDecimale'] = '%02d' % amount_cents
if reason != None:
self['libelle'] = reason
self.submit()
# look for known errors
content = unicode(self.response().get_data(), 'utf-8')
insufficient_amount_message = u'Montant insuffisant.'
maximum_allowed_balance_message = u'Solde maximum autorisé dépassé.'
if content.find(insufficient_amount_message) != -1:
raise TransferError('The amount you tried to transfer is too low.')
if content.find(maximum_allowed_balance_message) != -1:
raise TransferError('The maximum allowed balance for the target account has been / would be reached.')
# look for the known "all right" message
ready_for_transfer_message = u'Vous allez effectuer un virement'
if not content.find(ready_for_transfer_message):
raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message)
# submit the last form
self.select_form(nr=0)
submit_date = datetime.now()
self.submit()
# look for the known "everything went well" message
content = unicode(self.response().get_data(), 'utf-8')
transfer_ok_message = u'Vous venez d\'effectuer un virement du compte'
if not content.find(transfer_ok_message):
raise TransferError('The expected message "%s" was not found.' % transfer_ok_message)
# We now have to return a Transfer object
# the final page does not provide any transfer id, so we'll use the submit date
transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S'))
transfer.amount = amount
transfer.origin = account
transfer.recipient = to
transfer.date = submit_date
return transfer