Exemplo n.º 1
0
 def get_list(self):
     ids = set()
     for td in self.document.xpath('.//td[@nowrap="nowrap"]'):
         account = Account()
         link = td.xpath('.//a')[0]
         account._index = int(re.search('\d', link.attrib['href']).group(0))
         if not account._index in ids:
             ids.add(account._index)
             account.id = unicode(link.text.strip())
             account.label = account.id
             urltofind = './/a[@href="' + link.attrib['href'] + '"]'
             linkbis = self.document.xpath(urltofind).pop()
             if linkbis.text == link.text:
                 linkbis = self.document.xpath(urltofind)[1]
             account.balance = Decimal(linkbis.text.replace('.', '').\
                                       replace(' ', '').replace(',', '.'))
             account.coming = NotAvailable
             yield account
Exemplo n.º 2
0
 def get_list(self):
     ids = set()
     for td in self.document.xpath('.//td[@nowrap="nowrap"]'):
         account = Account()
         link = td.xpath('.//a')[0]
         account._index = int(re.search('\d', link.attrib['href']).group(0))
         if not account._index in ids:
             ids.add(account._index)
             account.id = unicode(link.text.strip())
             account.label = account.id
             urltofind = './/a[@href="' + link.attrib['href'] + '"]'
             linkbis = self.document.xpath(urltofind).pop()
             if linkbis.text == link.text:
                 linkbis = self.document.xpath(urltofind)[1]
             account.balance = Decimal(linkbis.text.replace('.', '').\
                                       replace(' ', '').replace(',', '.'))
             account.coming = NotAvailable
             yield account
Exemplo n.º 3
0
    def iter_accounts(self):
        for line in self.doc.xpath(
                '//script[@id="initial-state"]')[0].text.split('\n'):
            m = re.search('window.__INITIAL_STATE__ = (.*);', line)
            if m:
                data = list(flatten(json.loads(literal_eval(m.group(1)))))
                break
        else:
            assert False, "data was not found"

        assert data.count(
            'display_account_number') == 1, 'there should be exactly one card'

        acc = Account()
        acc.id = 'XXX-%s' % data[1 + data.index('display_account_number')]
        acc.label = '%s %s' % (data[1 + data.index('description')],
                               data[1 + data.index('embossed_name')])
        acc._index = data[1 + data.index('sorted_index')]
        acc._token = data[1 + data.index('account_token')]
        yield acc