Added comapny descriptions
This commit is contained in:
parent
40a8e5fa5c
commit
79bf11aa8f
@ -645,7 +645,7 @@ a {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#tab-1, #tab-2{
|
||||
#tab-1, #tab-2, #tab-3{
|
||||
background-color: #1E1E1E;
|
||||
color: #fff;
|
||||
border-left: none;
|
||||
@ -655,4 +655,10 @@ a {
|
||||
|
||||
.tab--selected{
|
||||
background-color: #111111 !important;
|
||||
}
|
||||
|
||||
#company-desritpion{
|
||||
padding: 3rem 1rem;
|
||||
margin: 0;
|
||||
background-color: #111111;
|
||||
}
|
24
finance.py
24
finance.py
@ -11,6 +11,8 @@ import pandas as pd
|
||||
import datetime
|
||||
import time
|
||||
from pandas_datareader import data
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
# Load data
|
||||
stock_list = ['MMM', 'ABT', 'ABBV', 'ABMD', 'ACN', 'ATVI', 'ADBE', 'AMD', 'AAP', 'AES', 'AFL', 'A', 'APD', 'AKAM',
|
||||
@ -155,6 +157,9 @@ app.layout = html.Div(
|
||||
dcc.Graph(id='price-dividends', figure=mean_prices_and_dividends_figure,
|
||||
config={'displayModeBar': False}, animate=True),
|
||||
]),
|
||||
dcc.Tab(id='tab-3', label='Copmany description', value='tab-3', children=[
|
||||
html.Div(id="company-desritpion"),
|
||||
]),
|
||||
]),
|
||||
dash_table.DataTable(
|
||||
id='stock_price_table',
|
||||
@ -170,6 +175,25 @@ app.layout = html.Div(
|
||||
)
|
||||
|
||||
|
||||
|
||||
# Callback for scraping company description
|
||||
@app.callback(Output('company-desritpion', 'children'), [Input('table_selector', 'value')])
|
||||
def update_graph(selected_dropdown_value):
|
||||
url = 'https://finance.yahoo.com/quote/{company}/profile?p={company}'.format(company=selected_dropdown_value)
|
||||
page = requests.get(url)
|
||||
soup = BeautifulSoup(page.content, 'html.parser')
|
||||
comp_name = soup.find(id="Main").h3.text
|
||||
description = soup.find_all('section', class_='quote-sub-section')[0].p.text
|
||||
|
||||
return dcc.Markdown('''
|
||||
|
||||
# [{comp_name}]({url})
|
||||
|
||||
{description}
|
||||
'''.format(comp_name=comp_name,description=description,url=url))
|
||||
|
||||
|
||||
|
||||
# Callback for downloading file
|
||||
@app.callback(
|
||||
Output("download-data", "data"),
|
||||
|
Loading…
Reference in New Issue
Block a user