dtaabase caller connected and bugfix

This commit is contained in:
Your Name
2022-01-24 18:40:06 +00:00
parent a25c82128c
commit 5d7ec03d41
5 changed files with 42 additions and 15 deletions

View File

@@ -133,7 +133,7 @@ def updateCrypto():
response = requests.get(url)
data = response.json()
print(data)
sys.exit()
stock_info = {}
@@ -270,18 +270,23 @@ def updateNews():
response = requests.get(url)
data = response.json()
#load user settings
headlines = data
headline_sources = [headline['source'] for headline in headlines]
except Exception as e:
print('news ettings not used', e)
#if no settings just get top headlines
headlines = newsapi.get_top_headlines()
headlines = newsapi.get_top_headlines()['articles']
headline_sources = [headline['source']['name'] for headline in headlines]
headline_titles = [headline['title'] for headline in headlines['articles']]
headline_sources = [headline['source']['name'] for headline in headlines['articles']]
headline_times = [headline['publishedAt']for headline in headlines['articles']]
headline_titles = [headline['title'] for headline in headlines]
headline_times = [headline['publishedAt'] for headline in headlines]
headlines = list(zip(headline_titles, headline_sources, headline_times))
print(headlines)
all_settings['headlines'] = headlines
json.dump(all_settings, open('csv/news_settings.json', 'w+'))
@@ -289,6 +294,7 @@ def updateNews():
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
logf.write(str(e))