Esempio n. 1
0
def getDetails(enterprise):
    logging.info('Getting Details of Company %s', enterprise[0])

    edp,name = enterprise[0],enterprise[1]
    d = dict()
    d['id'] = edp
    d['name'] = name
    d['register_date'] = datetime.now().isoformat()
    page = openUrl(buildUrl(URL_EDETAIL, 'CodCVM=' + edp))

    # Company Data
    att = getTables(page, 'panel1a')
    for table in att[:3]:
        for row in getRows(table): rowToDict(row,d)

    #print tostring(page)
    att = HtmlElement(page).get_element_by_id('panel1a')
    d['trading_codes'] = [ l.text for l in HtmlElement(att).find_class('LinkCodNeg') ]
    att = d['industry_classification'].split('/')
    d['sector'] = att[0].strip()
    d['subsector'] = att[1].strip()
    d['segment'] = att[2].strip()
    d['detailwebsite'] = buildUrl(URL_RESUMO, 'codigoCvm=' + edp, 'idioma=pt-BR')
    if 'website' in d: d['website'] = urlparse.urlsplit(d['website'], 'http').geturl()

    return d
Esempio n. 2
0
def getDfpConBPA(url, infos):
    logging.info('Getting DFs Consolidadas - Balanco Patrimonial Ativo')
    t = dict()
    page = HtmlElement(openUrl(url)) 
    table = page.get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Caixa
    cxa = toInt(t['1.01.01'][1])*m if '1.01.01' in t else 0
    apf = toInt(t['1.01.02'][1])*m if '1.01.02' in t else 0
    infos['CAIXA'] = cxa + apf
Esempio n. 3
0
def getDftDemRes(url, infos):
    logging.info('Getting DFs Consolidadas - Demonstracao do Resultado')
    t = dict()
    page = openUrl(url) 
    table = HtmlElement(page).get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Receita Liquida
    infos['RL'] = toInt(t['3.01'][1])*m if '3.01' in t else 0
    # Lucro Liquito
    infos['LL'] = next((toInt(v[1])*m for k,v in t.iteritems() if re.match('^Lucro.+odo$', v[0])), 0)
Esempio n. 4
0
def getDftDemRes(nsd, nsr, infos, params_geral=PARMS_GERAL):
    logging.info('Getting DFs Consolidadas - Demonstracao do Resultado - %s %s', nsd, nsr)
    t = dict()
    page = openUrl(buildUrl(URL_FDF, params_geral, PARMS_BPP, 
        'NumeroSequencialDocumento=' + nsd, 'NumeroSequencialRegistroCvm=' + nsr, 
        'Informacao=2', 'Demonstracao=4'))
    table = HtmlElement(page).get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Receita Liquida
    infos['RL'] = toInt(t['3.01'][1])*m if '3.01' in t else 0
    # Lucro Liquito
    infos['LL'] = toInt(t['3.11'][1])*m if '3.11' in t else 0
Esempio n. 5
0
def getDfpConBPA(nsd, nsr, infos):
    logging.info('Getting DFs Consolidadas - Balanco Patrimonial Ativo - %s %s', nsd, nsr)
    t = dict()
    page = HtmlElement(openUrl(buildUrl(URL_FDF, PARMS_GERAL, PARMS_BPP, 
        'NumeroSequencialDocumento=' + nsd, 'NumeroSequencialRegistroCvm=' + nsr, 
        'Informacao=2', 'Demonstracao=2')))
    table = page.get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Caixa
    cxa = toInt(t['1.01.01'][1])*m if '1.01.01' in t else 0
    apf = toInt(t['1.01.02'][1])*m if '1.01.02' in t else 0
    infos['CAIXA'] = cxa + apf
Esempio n. 6
0
def getDfpConBPP(nsd, nsr, infos):
    logging.info('Getting DFs Consolidadas - Balanco Patrimonial Passivo - %s %s', nsd, nsr)
    t = dict()
    page = openUrl(buildUrl(URL_FDF, PARMS_GERAL, PARMS_BPP, 
        'NumeroSequencialDocumento=' + nsd, 'NumeroSequencialRegistroCvm=' + nsr, 
        'Informacao=2', 'Demonstracao=3'))
    table = HtmlElement(page).get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Patrimonio Liquido
    infos['PL'] = toInt(t['2.03'][1])*m if '2.03' in t else 0
    # Divida Bruta
    CP = toInt(t['2.01.04'][1])*m if '2.01.04' in t else 0
    LP = toInt(t['2.02.01'][1])*m if '2.02.01' in t else 0
    infos['DB'] = CP + LP
Esempio n. 7
0
def getDfpConBPP(url, infos):
    logging.info('Getting DFs Consolidadas - Balanco Patrimonial Passivo')
    t = dict()
    page = openUrl(url) 
    table = HtmlElement(page).get_element_by_id(TABLE_BPP)
    for row in getRows(table): rowToDict(row, t)

    # Multiplicador
    m = getMultiplicador(page)

    # Patrimonio Liquido
    infos['PL'] = toInt(t['2.03'][1])*m if '2.03' in t else 0
    # Divida Bruta
    CP = toInt(t['2.01.04'][1])*m if '2.01.04' in t else 0
    LP = toInt(t['2.02.01'][1])*m if '2.02.01' in t else 0
    infos['DB'] = CP + LP
    # Dividendos
    Div = toInt(t['2.01.05.02.01'][1])*m if '2.01.05.02.01' in t else 0
    infos['DIV'] = Div