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
def get_list(self): table = self.parser.select(self.document.getroot(), "#tab-corps", 1) for tr in self.parser.select(table, "tr", "many"): tdname, tdid, tdagency, tdbalance = [td.text_content().strip() for td in self.parser.select(tr, "td", 4)] # it has empty rows - ignore those without the necessary info if all((tdname, tdid, tdbalance)): account = Account() account.label = to_unicode(tdname) account.id = to_unicode(tdid.replace(u"\xa0", "").replace(" ", "")) account._agency = to_unicode(tdagency) account._is_card = False account.balance = Decimal(Transaction.clean_amount(tdbalance)) account.currency = account.get_currency(tdbalance) yield account
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
def get_list(self): table = self.parser.select(self.document.getroot(), '#tab-corps', 1) for tr in self.parser.select(table, 'tr', 'many'): tdname, tdid, tdagency, tdbalance = [td.text_content().strip() for td in self.parser.select(tr, 'td', 4)] # it has empty rows - ignore those without the necessary info if all((tdname, tdid, tdbalance)): account = Account() account.label = to_unicode(tdname) account.id = to_unicode(tdid.replace(u'\xa0', '').replace(' ', '')) account._agency = to_unicode(tdagency) account._is_card = False account.balance = Decimal(Transaction.clean_amount(tdbalance)) account.currency = account.get_currency(tdbalance) yield account
def get_list(self): table = self.parser.select(self.document.getroot(), '#tab-corps', 1) for tr in self.parser.select(table, 'tr', 'many'): tdname, tdid, tdagency, tdbalance = [td.text_content().strip() for td in self.parser.select(tr, 'td', 4)] # it has empty rows - ignore those without the necessary info if all((tdname, tdid, tdbalance)): account = Account() account.label = to_unicode(tdname) account.type = self.TYPES.get(account.label, Account.TYPE_UNKNOWN) account.id = to_unicode(tdid.replace(u'\xa0', '').replace(' ', '')) account._agency = to_unicode(tdagency) account._is_card = False account.balance = Decimal(Transaction.clean_amount(tdbalance)) account.currency = account.get_currency(tdbalance) yield account