本文整理匯總了Python中weboob.capabilities.bank.Transaction.parse方法的典型用法代碼示例。如果您正苦於以下問題:Python Transaction.parse方法的具體用法?Python Transaction.parse怎麽用?Python Transaction.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weboob.capabilities.bank.Transaction
的用法示例。
在下文中一共展示了Transaction.parse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import parse [as 別名]
def get_transactions(self):
table = self.document.findall('//tbody')[0]
for tr in table.xpath('tr'):
textdate = tr.find('td[@class="op_date"]').text_content()
textraw = tr.find('td[@class="op_label"]').text_content().strip()
# The id will be rewrite
op = Transaction(1)
amount = op.clean_amount(tr.find('td[@class="op_amount"]').text_content())
id = hashlib.md5(textdate + textraw.encode('utf-8') + amount.encode('utf-8')).hexdigest()
op.id = id
op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
raw = textraw)
# force the use of website category
op.category = unicode(tr.find('td[@class="op_type"]').text)
op.amount = Decimal(amount)
yield op
示例2: get_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import parse [as 別名]
def get_transactions(self, index):
i = 0
for table in self.document.xpath('//table'):
try:
textdate = table.find('.//td[@class="date"]').text_content()
except AttributeError:
continue
# Do not parse transactions already parsed
if i < index:
i += 1
continue
if textdate == 'hier':
textdate = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
elif textdate == "aujourd'hui":
textdate = date.today().strftime('%d/%m/%Y')
else:
frenchmonth = textdate.split(' ')[1]
month = self.monthvalue[frenchmonth]
textdate = textdate.replace(' ', '')
textdate = textdate.replace(frenchmonth, '/%s/' %month)
# We use lower for compatibility with old website
textraw = table.find('.//td[@class="lbl"]').text_content().strip().lower()
# The id will be rewrite
op = Transaction(1)
amount = op.clean_amount(table.xpath('.//td[starts-with(@class, "amount")]')[0].text_content())
id = hashlib.md5(textdate.encode('utf-8') + textraw.encode('utf-8')
+ amount.encode('utf-8')).hexdigest()
op.id = id
op.parse(date = date(*reversed([int(x) for x in textdate.split('/')])),
raw = textraw)
category = table.find('.//td[@class="picto"]/span')
category = unicode(category.attrib['class'].split('-')[0].lower())
try:
op.category = self.catvalue[category]
except:
op.category = category
op.amount = Decimal(amount)
yield op