本文整理汇总了Python中weboob.capabilities.bank.Account._link方法的典型用法代码示例。如果您正苦于以下问题:Python Account._link方法的具体用法?Python Account._link怎么用?Python Account._link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.bank.Account
的用法示例。
在下文中一共展示了Account._link方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
for tr in self.document.xpath('//table[@class="ca-table"]/tr'):
if not tr.attrib.get('class', '').startswith('colcelligne'):
continue
cols = tr.findall('td')
if not cols:
continue
account = Account()
account.id = self.parser.tocleanstring(cols[self.COL_ID])
account.label = self.parser.tocleanstring(cols[self.COL_LABEL])
account.type = self.TYPES.get(account.label, Account.TYPE_UNKNOWN)
balance = self.parser.tocleanstring(cols[self.COL_VALUE])
# we have to ignore those accounts, because using NotAvailable
# makes boobank and probably many others crash
if balance in ('indisponible', ''):
continue
account.balance = Decimal(Transaction.clean_amount(balance))
account.currency = account.get_currency(self.parser.tocleanstring(cols[self.COL_CURRENCY]))
account._link = None
a = cols[0].find('a')
if a is not None:
account._link = a.attrib['href'].replace(' ', '%20')
yield account
示例2: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
accounts = []
previous_account = None
noaccounts = self.get_from_js('_js_noMvts =', ';')
if noaccounts is not None:
assert 'avez aucun compte' in noaccounts
return []
txt = self.get_from_js('_data = new Array(', ');', is_list=True)
if txt is None:
raise BrowserUnavailable('Unable to find accounts list in scripts')
data = json.loads('[%s]' % txt.replace("'", '"'))
for line in data:
a = Account()
a.id = line[self.COL_ID].replace(' ', '')
if re.match(r'Classement=(.*?):::Banque=(.*?):::Agence=(.*?):::SScompte=(.*?):::Serie=(.*)', a.id):
a.id = str(CleanDecimal().filter(a.id))
a._acc_nb = a.id.split('_')[0] if len(a.id.split('_')) > 1 else None
a.label = MyStrip(line[self.COL_LABEL], xpath='.//div[@class="libelleCompteTDB"]')
# This account can be multiple life insurance accounts
if a.label == 'ASSURANCE VIE-BON CAPI-SCPI-DIVERS *':
continue
a.balance = Decimal(FrenchTransaction.clean_amount(line[self.COL_BALANCE]))
a.currency = a.get_currency(line[self.COL_BALANCE])
a.type = self.get_account_type(a.label)
# The parent account must be created right before
if a.type == Account.TYPE_CARD:
# duplicate
if find_object(accounts, id=a.id):
self.logger.warning('Ignoring duplicate card %r', a.id)
continue
a.parent = previous_account
if line[self.COL_HISTORY] == 'true':
a._inv = False
a._link = self.get_history_link()
a._args = self.make__args_dict(line)
else:
a._inv = True
a._args = {'_ipc_eventValue': line[self.COL_ID],
'_ipc_fireEvent': line[self.COL_FIRE_EVENT],
}
a._link = self.doc.xpath('//form[@name="changePageForm"]')[0].attrib['action']
if a.type is Account.TYPE_CARD:
a.coming = a.balance
a.balance = Decimal('0.0')
accounts.append(a)
previous_account = a
return accounts
示例3: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
account_type = Account.TYPE_UNKNOWN
accounts = []
for tr in self.document.xpath('//table[@class="ecli"]/tr'):
if tr.attrib.get('class', '') == 'entete':
account_type = self.ACCOUNT_TYPES.get(tr.find('th').text.strip(), Account.TYPE_UNKNOWN)
continue
tds = tr.findall('td')
balance = tds[-1].text.strip()
if balance == '':
continue
account = Account()
account.label = u' '.join([txt.strip() for txt in tds[0].itertext()])
account.label = re.sub(u'[ \xa0\u2022\r\n\t]+', u' ', account.label).strip()
account.id = re.findall('(\d+)', account.label)[0]
account.balance = Decimal(FrenchTransaction.clean_amount(balance))
account.currency = account.get_currency(balance)
account.type = account_type
m = re.search(r"javascript:submitForm\(([\w_]+),'([^']+)'\);", tds[0].find('a').attrib['onclick'])
if not m:
self.logger.warning('Unable to find link for %r' % account.label)
account._link = None
else:
account._link = m.group(2)
accounts.append(account)
return accounts
示例4: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
TABLE_XPATH = '//table[caption[@class="caption tdb-cartes-caption" or @class="ca-table caption"]]'
cards_tables = self.document.xpath(TABLE_XPATH)
currency = self.document.xpath('//table/caption//span/text()[starts-with(.,"Montants en ")]')[0].replace("Montants en ", "") or None
if cards_tables:
self.logger.debug('There are several cards')
xpaths = {
'_id': './caption/span[@class="tdb-cartes-num"]',
'label1': './caption/span[contains(@class, "tdb-cartes-carte")]',
'label2': './caption/span[@class="tdb-cartes-prop"]',
'balance': './/tr/td[@class="cel-num"]',
'currency': '//table/caption//span/text()[starts-with(.,"Montants en ")]',
'link': './/tr//a/@href[contains(., "fwkaction=Detail")]',
}
else:
self.logger.debug('There is only one card')
xpaths = {
'_id': './/tr/td[@class="cel-texte"]',
'label1': './/tr[@class="ligne-impaire ligne-bleu"]/th',
'label2': './caption/span[@class="tdb-cartes-prop"]/b',
'balance': './/tr[last()-1]/td[@class="cel-num"] | .//tr[last()-2]/td[@class="cel-num"]',
'currency': '//table/caption//span/text()[starts-with(.,"Montants en ")]',
}
TABLE_XPATH = '(//table[@class="ca-table"])[1]'
cards_tables = self.document.xpath(TABLE_XPATH)
for table in cards_tables:
get = lambda name: self.parser.tocleanstring(table.xpath(xpaths[name])[0])
account = Account()
account.type = account.TYPE_CARD
account.id = ''.join(get('_id').split()[1:])
account._id = ' '.join(get('_id').split()[1:])
account.label = '%s - %s' % (get('label1'),
re.sub('\s*-\s*$', '', get('label2')))
try:
account.balance = Decimal(Transaction.clean_amount(table.xpath(xpaths['balance'])[-1].text))
account.currency = account.get_currency(self.document
.xpath(xpaths['currency'])[0].replace("Montants en ", ""))
if not account.currency and currency:
account.currency = Account.get_currency(currency)
except IndexError:
account.balance = Decimal('0.0')
if 'link' in xpaths:
try:
account._link = table.xpath(xpaths['link'])[-1]
except IndexError:
account._link = None
else:
account._link = re.sub('[\n\r\t]+', '', account._link)
else:
account._link = self.url
account._perimeter = self.browser.current_perimeter
yield account
示例5: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
accounts = []
txt = self.get_from_js('_data = new Array(', ');', is_list=True)
if txt is None:
raise BrokenPageError('Unable to find accounts list in scripts')
data = json.loads('[%s]' % txt.replace("'", '"'))
for line in data:
a = Account()
a.id = line[self.COL_ID].replace(' ', '')
a._acc_nb = a.id.split('_')[0] if len(a.id.split('_')) > 1 else None
fp = StringIO(unicode(line[self.COL_LABEL]).encode(self.browser.ENCODING))
a.label = self.parser.tocleanstring(self.parser.parse(fp, self.browser.ENCODING).xpath('//div[@class="libelleCompteTDB"]')[0])
# This account can be multiple life insurance accounts
if a.label == 'ASSURANCE VIE-BON CAPI-SCPI-DIVERS *':
continue
a.balance = Decimal(FrenchTransaction.clean_amount(line[self.COL_BALANCE]))
a.currency = a.get_currency(line[self.COL_BALANCE])
a.type = self.get_account_type(a.label)
if line[self.COL_HISTORY] == 'true':
a._inv = False
a._link = self.get_history_link()
a._args = {'_eventId': 'clicDetailCompte',
'_ipc_eventValue': '',
'_ipc_fireEvent': '',
'deviseAffichee': 'DEVISE',
'execution': self.get_execution(),
'idCompteClique': line[self.COL_ID],
}
else:
a._inv = True
a._args = {'_ipc_eventValue': line[self.COL_ID],
'_ipc_fireEvent': line[self.COL_FIRE_EVENT],
}
a._link = self.document.xpath('//form[@name="changePageForm"]')[0].attrib['action']
if a.id.find('_CarteVisa') >= 0:
accounts[-1]._card_ids.append(a._args)
if not accounts[-1].coming:
accounts[-1].coming = Decimal('0.0')
accounts[-1].coming += a.balance
continue
a._card_ids = []
accounts.append(a)
return accounts
示例6: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
account_type = Account.TYPE_UNKNOWN
accounts = []
for tr in self.doc.xpath('//div[@class="finance"]/form/table[@class="ecli"]/tr'):
if tr.attrib.get('class', '') == 'entete':
account_type = self.ACCOUNT_TYPES.get(tr.find('th').text.strip(), Account.TYPE_UNKNOWN)
continue
tds = tr.findall('td')
a = tds[0].find('a')
# Skip accounts that can't be accessed
if a is None:
continue
balance = tds[-1].text.strip()
account = Account()
account.label = u' '.join([txt.strip() for txt in tds[0].itertext()])
account.label = re.sub(u'[ \xa0\u2022\r\n\t]+', u' ', account.label).strip()
# take "N° (FOO123 456)" but "N° (FOO123) MR. BAR"
account.id = re.search(r'N° (\w+( \d+)*)', account.label).group(1).replace(' ', '')
account.type = account_type
for patt, type in self.ACCOUNT_TYPES2.items():
if patt in account.label.lower():
account.type = type
break
if balance:
account.balance = Decimal(FrenchTransaction.clean_amount(balance))
account.currency = account.get_currency(balance)
if 'onclick' in a.attrib:
m = re.search(r"javascript:submitForm\(([\w_]+),'([^']+)'\);", a.attrib['onclick'])
if not m:
self.logger.warning('Unable to find link for %r' % account.label)
account._link = None
else:
account._link = m.group(2)
else:
account._link = a.attrib['href'].strip()
if accounts and accounts[-1].label == account.label and account.type == Account.TYPE_PEA:
self.logger.warning('%s seems to be a duplicate of %s, skipping', account, accounts[-1])
continue
accounts.append(account)
return accounts
示例7: populate
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def populate(self, accounts):
cards = []
for account in accounts:
for li in self.doc.xpath('//li[@class="nav-category"]'):
title = CleanText().filter(li.xpath('./h3'))
for a in li.xpath('./ul/li//a'):
label = CleanText().filter(a.xpath('.//span[@class="nav-category__name"]'))
balance_el = a.xpath('.//span[@class="nav-category__value"]')
balance = CleanDecimal(replace_dots=True, default=NotAvailable).filter(balance_el)
if 'CARTE' in label and balance:
acc = Account()
acc.balance = balance
acc.label = label
acc.currency = FrenchTransaction.Currency().filter(balance_el)
acc._link = Link().filter(a.xpath('.'))
acc._history_page = acc._link
acc.id = acc._webid = Regexp(pattern='([^=]+)$').filter(Link().filter(a.xpath('.')))
acc.type = Account.TYPE_CARD
if not acc in cards:
cards.append(acc)
elif account.label == label and account.balance == balance:
if not account.type:
account.type = AccountsPage.ACCOUNT_TYPES.get(title, Account.TYPE_UNKNOWN)
if account.type == Account.TYPE_LOAN:
account._history_page = None
elif account.type in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_MARKET):
account._history_page = re.sub('/$', '', Link().filter(a.xpath('.')))
elif '/compte/cav' in a.attrib['href'] or not 'titulaire' in self.url:
account._history_page = self.browser.other_transactions
else:
account._history_page = self.browser.budget_transactions
account._webid = Attr(None, 'data-account-label').filter(a.xpath('.//span[@class="nav-category__name"]'))
accounts.extend(cards)
示例8: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
account_type = Account.TYPE_UNKNOWN
for tr in self.document.xpath('//table[@class="ca-table"]/tr'):
try:
title = tr.xpath('.//h3/text()')[0].lower().strip()
except IndexError:
pass
else:
account_type = self.TYPES.get(title, Account.TYPE_UNKNOWN)
if not tr.attrib.get('class', '').startswith('colcelligne'):
continue
cols = tr.findall('td')
if not cols or len(cols) < self.NB_COLS:
continue
account = Account()
account.id = self.parser.tocleanstring(cols[self.COL_ID])
account.label = self.parser.tocleanstring(cols[self.COL_LABEL])
account.type = account_type or self.TYPES.get(account.label, Account.TYPE_UNKNOWN)
balance = self.parser.tocleanstring(cols[self.COL_VALUE])
# we have to ignore those accounts, because using NotAvailable
# makes boobank and probably many others crash
if balance in ('indisponible', ''):
continue
account.balance = Decimal(Transaction.clean_amount(balance))
account.currency = account.get_currency(self.parser.tocleanstring(cols[self.COL_CURRENCY]))
account._link = None
self.set_link(account, cols)
account._perimeter = self.browser.current_perimeter
yield account
示例9: get_accounts
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_accounts(self):
for el in self.doc.getroot().cssselect('div#content tr.row'):
account = Account()
balance = el.cssselect('td.Balance')[0].text
account.balance = Decimal(Transaction.clean_amount(balance))
account.id = el.cssselect('span')[0].text.strip()
account.currency = u'NZD' # TODO: handle other currencies
if el.cssselect('td.AccountName > a'):
label_el = el.cssselect('td.AccountName > a')[0]
account._link = label_el.get('href')
else:
label_el = el.cssselect('td.AccountName')[0]
account._link = None
account.label = unicode(label_el.text.strip())
yield account
示例10: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
iban = None
for tr in self.document.xpath('//table[@class="ca-table"]/tr'):
if not tr.attrib.get('class', '').startswith('colcelligne'):
continue
cols = tr.findall('td')
if not cols or len(cols) < 7:
continue
account = Account()
account.id = self.parser.tocleanstring(cols[self.COL_ID])
account.label = self.parser.tocleanstring(cols[self.COL_LABEL])
account.type = self.TYPES.get(account.label, Account.TYPE_UNKNOWN)
balance = self.parser.tocleanstring(cols[self.COL_VALUE])
# we have to ignore those accounts, because using NotAvailable
# makes boobank and probably many others crash
if balance in ('indisponible', ''):
continue
account.balance = Decimal(Transaction.clean_amount(balance))
account.currency = account.get_currency(self.parser.tocleanstring(cols[self.COL_CURRENCY]))
account._link = None
a = cols[0].find('a')
if a is not None:
account._link = a.attrib['href'].replace(' ', '%20')
page = self.browser.get_page(self.browser.openurl(account._link))
url = page.get_iban_url()
if url:
page = self.browser.get_page(self.browser.openurl(url))
iban = account.iban = page.get_iban()
elif iban:
# In case there is no available IBAN on this account (for
# example saving account), calculate it from the previous
# IBAN.
bankcode = iban[4:9]
counter = iban[9:14]
key = 97 - ((int(bankcode) * 89 + int(counter) * 15 + int(account.id) * 3) % 97)
account.iban = iban[:4] + bankcode + counter + account.id + str(key)
yield account
示例11: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
names = set()
for li in self.document.xpath('//div[@class="affichMontant"]/ul/li/a'):
account = Account()
account.label = unicode(li.cssselect('div.row-lib u')[0].text.strip())
account.id = re.sub('[ \.\-]+', '', account.label)
while account.id in names:
account.id = account.id + '1'
names.add(account.id)
account.balance = Decimal(li.cssselect('p.row-right')[0].text.strip().replace(' ', '').replace(u'\xa0', '').replace(',', ''))
account._link = li.attrib['href']
yield account
示例12: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
for div in self.doc.xpath('.//div[@id="card-details"]'):
a = Account()
a.id = CleanText().filter(div.xpath('.//span[@class="acc-num"]'))
a.label = CleanText().filter(div.xpath('.//span[@class="card-desc"]'))
if "carte" in a.label.lower():
a.type = Account.TYPE_CARD
balance = CleanText().filter(div.xpath('.//span[@class="balance-data"]'))
if balance in (u'Indisponible', u'Indisponible Facturation en cours', ''):
a.balance = NotAvailable
else:
a.currency = a.get_currency(balance)
a.balance = - abs(CleanDecimal(replace_dots=a.currency == 'EUR').filter(balance))
# Cancel card don't have a link to watch history
link = self.doc.xpath('.//div[@class="wide-bar"]/h3/a')
if len(link) == 1:
a._link = link[0].attrib['href']
else:
a._link = None
yield a
示例13: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
for box in self.document.getroot().cssselect('div.roundedBox div.contentBox'):
a = Account()
a.id = self.parser.tocleanstring(box.xpath('.//tr[@id="summaryImageHeaderRow"]//div[@class="summaryTitles"]')[0])
a.label = self.parser.tocleanstring(box.xpath('.//span[@class="cardTitle"]')[0])
balance = self.parser.tocleanstring(self.parser.select(box, 'td#colOSBalance div.summaryValues', 1))
if balance in (u'Indisponible', u'Indisponible Facturation en cours', ''):
a.balance = NotAvailable
else:
a.balance = - abs(Decimal(Transaction.clean_amount(balance)))
a.currency = a.get_currency(balance)
a._link = self.parser.select(box, 'div.summaryTitles a.summaryLink', 1).attrib['href']
yield a
示例14: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
for div in self.document.xpath('.//div[@id="card-details"]'):
a = Account()
a.id = self.parser.tocleanstring(div.xpath('.//span[@class="acc-num"]')[0])
a.label = self.parser.tocleanstring(div.xpath('.//span[@class="card-desc"]')[0])
balance = self.parser.tocleanstring(div.xpath('.//span[@class="balance-data"]')[0])
if balance in (u"Indisponible", u"Indisponible Facturation en cours", ""):
a.balance = NotAvailable
else:
a.balance = -abs(Decimal(Transaction.clean_amount(balance)))
a.currency = a.get_currency(balance)
a._link = self.document.xpath('.//div[@class="wide-bar"]/h3/a')[0].attrib["href"]
yield a
示例15: get_list
# 需要导入模块: from weboob.capabilities.bank import Account [as 别名]
# 或者: from weboob.capabilities.bank.Account import _link [as 别名]
def get_list(self):
rib = None
currency = None
for script in self.document.xpath('//script'):
if script.text is None:
continue
m = re.search('var rib = "(\d+)"', script.text)
if m:
rib = m.group(1)
m = re.search("var devise='(\w+)'", script.text)
if m:
currency = m.group(1)
if all((rib, currency)):
break
if not all((rib, currency)):
self.logger.error('Unable to find rib or currency')
for tr in self.document.xpath('//table[@id="tab-corps"]//tr'):
tds = tr.findall('td')
if len(tds) != 3:
continue
account = Account()
account.type = Account.TYPE_CARD
account.label = self.parser.tocleanstring(tds[self.COL_LABEL])
if len(account.label) == 0:
continue
link = tds[self.COL_ID].xpath('.//a')[0]
m = re.match(r"changeCarte\('(\d+)','(\d+)','([^']+)'\);.*", link.attrib['onclick'])
if not m:
self.logger.error('Unable to parse link %r' % link.attrib['onclick'])
continue
account._link_num = m.group(1) #useless
account._link = m.group(2)
account.id = m.group(2) + account._link_num
account._link_date = urllib.quote(m.group(3))
account._link_rib = rib
account._link_currency = currency
account._is_card = True
tdbalance = self.parser.tocleanstring(tds[self.COL_BALANCE])
account.balance = - Decimal(Transaction.clean_amount(tdbalance))
account.currency = account.get_currency(tdbalance)
yield account