def iter_accounts(self): if not self.islogged: self.login() data = self.browser.open( "https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act" ).content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = self.browser.open( "https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act" ).content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: raise ParseError() else: raise ParseError() for tr in tree.xpath('/html/body//table[contains(@class, "Tb")]/tr'): if tr.get('class', None) not in ('LnTit', 'LnTot', 'LnMnTiers', None): account = Account() td = tr.xpath('td') a = td[1].xpath('a') account.label = unicode(a[0].text).strip() href = a[0].get('href') m = match(r"javascript:releve\((.*),'(.*)','(.*)'\)", href) if not m: continue account.id = unicode(m.group(1) + m.group(2) + m.group(3)) account._cmbvaleur = m.group(1) account._cmbvaleur2 = m.group(2) account._cmbtype = m.group(3) balance = u''.join([txt.strip() for txt in td[2].itertext()]) balance = balance.replace(',', '.').replace(u"\xa0", '') account.balance = Decimal(balance) span = td[4].xpath('a/span') if len(span): coming = span[0].text.replace(' ', '').replace(',', '.') coming = coming.replace(u"\xa0", '') account.coming = Decimal(coming) else: account.coming = NotAvailable yield account
def iter_accounts(self): if not self.islogged: self.login() data = self.browser.open("https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act").content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = self.browser.open("https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act").content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: raise ParseError() else: raise ParseError() for tr in tree.xpath('/html/body//table[contains(@class, "Tb")]/tr'): if tr.get('class', None) not in ('LnTit', 'LnTot', 'LnMnTiers', None): account = Account() td = tr.xpath('td') a = td[1].xpath('a') account.label = unicode(a[0].text).strip() href = a[0].get('href') m = match(r"javascript:releve\((.*),'(.*)','(.*)'\)", href) if not m: continue account.id = unicode(m.group(1) + m.group(2) + m.group(3)) account._cmbvaleur = m.group(1) account._cmbvaleur2 = m.group(2) account._cmbtype = m.group(3) balance = u''.join([txt.strip() for txt in td[2].itertext()]) balance = balance.replace(',', '.').replace(u"\xa0", '') account.balance = Decimal(balance) span = td[4].xpath('a/span') if len(span): coming = span[0].text.replace(' ', '').replace(',', '.') coming = coming.replace(u"\xa0", '') account.coming = Decimal(coming) else: account.coming = NotAvailable yield account
def iter_accounts(self): if not self.cookie: self.login() def do_http(): if 'no_check' in self.config and self.config['no_check'].get() == "y": conn = HellHTTPS("www.cmb.fr") else: conn = HellHTTPS("www.cmb.fr", ca_file=self.AUTH_CERT, callBack=self.sslCallBack) conn.connect() headers = self.headers headers['Cookie'] = self.cookie conn.request("GET", '/domiweb/prive/particulier/releve/0-releve.act', {}, headers) response = conn.getresponse() data = response.read() conn.close() return data data = do_http() parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = do_http() parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: raise BrokenPageError() else: raise BrokenPageError() for tr in tree.xpath('/html/body//table[contains(@class, "Tb")]/tr'): if tr.get('class', None) not in ('LnTit', 'LnTot', 'LnMnTiers', None): account = Account() td = tr.xpath('td') a = td[1].xpath('a') account.label = unicode(a[0].text).strip() href = a[0].get('href') m = match(r"javascript:releve\((.*),'(.*)','(.*)'\)", href) if not m: continue account.id = unicode(m.group(1) + m.group(2) + m.group(3)) account._cmbvaleur = m.group(1) account._cmbvaleur2 = m.group(2) account._cmbtype = m.group(3) balance = u''.join([txt.strip() for txt in td[2].itertext()]) balance = balance.replace(',', '.').replace(u"\xa0", '') account.balance = Decimal(balance) span = td[4].xpath('a/span') if len(span): coming = span[0].text.replace(' ', '').replace(',', '.') coming = coming.replace(u"\xa0", '') account.coming = Decimal(coming) else: account.coming = NotAvailable yield account
def iter_accounts(self): if not self.cookie: self.login() def do_http(): if 'no_check' in self.config and self.config['no_check'].get( ) == "y": conn = HellHTTPS("www.cmb.fr") else: conn = HellHTTPS("www.cmb.fr", ca_file=self.AUTH_CERT, callBack=self.sslCallBack) conn.connect() headers = self.headers headers['Cookie'] = self.cookie conn.request("GET", '/domiweb/prive/particulier/releve/0-releve.act', {}, headers) response = conn.getresponse() data = response.read() conn.close() return data data = do_http() parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = do_http() parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: raise BrokenPageError() else: raise BrokenPageError() for tr in table[1].getiterator('tr'): if tr.get('class') != 'LnTit' and tr.get('class') != 'LnTot': account = Account() td = tr.xpath('td') a = td[1].xpath('a') account.label = unicode(a[0].text).strip() href = a[0].get('href') m = match(r"javascript:releve\((.*),'(.*)','(.*)'\)", href) if not m: continue account.id = unicode(m.group(1) + m.group(2) + m.group(3)) account._cmbvaleur = m.group(1) account._cmbvaleur2 = m.group(2) account._cmbtype = m.group(3) balance = td[2].text balance = balance.replace(',', '.').replace(u"\xa0", '') account.balance = Decimal(balance) span = td[4].xpath('a/span') if len(span): coming = span[0].text.replace(' ', '').replace(',', '.') coming = coming.replace(u"\xa0", '') account.coming = Decimal(coming) else: account.coming = NotAvailable yield account