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
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
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