Esempio n. 1
0
def run_single(notion):

    url = company_details_url(notion)
    with urllib.request.urlopen(url) as html_file:
        extractor = Extractor(html_file.read(), url)
        stock_main_data = extractor.content()

    with open('data/' + stock_main_data['head']['isin'] + '.json',
              'w') as json_file:
        json.dump(stock_main_data, json_file)
Esempio n. 2
0
def run_all(index_page):

    notions = []

    with urllib.request.urlopen(index_page) as html_file:
        indexer = Indexer(html_file)
        notions = indexer.get_links()

    for notion in notions:

        url = company_details_url(notion)
        with urllib.request.urlopen(url) as html_file:

            extractor = Extractor(html_file.read(), url)
            stock_main_data = extractor.content()

            if stock_main_data is not None:

                with open('data/' + stock_main_data['head']['isin'] + '.json',
                          'w') as json_file:
                    json.dump(stock_main_data, json_file)