def originals(req, p, ticker): number = req.params.get('num') url, page = seclib.latest_10k_financials(ticker) if number is not None: page = highlight_number_in_html(page, number) indices = extracttable.tables_start_indices_from_page(page) page = insert_anchors_into_html_at_indices(page, indices) p(template_originals(ticker, url, page))
def financials(req, p, ticker): try: url, page = seclib.latest_10k_financials(ticker) #tables = [t for t in tables if len(t) > 0] except: p(u'Could not find this ticker on SEC website') else: try: tables_html = extracttable.tables_html_from_page(page) tables = [extracttable.table_data_from_html(t) for t in tables_html] except: p(u'Failed to parse financial data from page: %s' % html.a(url, url)) else: p(template_financials(ticker, tables))