From 31d9b47a2ac0c105e431666f4ff65e6b24d94a59 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 17 Mar 2023 19:03:20 +0800 Subject: [PATCH] more news countries --- database_caller.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/database_caller.py b/database_caller.py index 26e938c..7a53641 100755 --- a/database_caller.py +++ b/database_caller.py @@ -516,24 +516,16 @@ def updateForex(api_key, logf): def updateNews(api_key, logf): - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?category=technology' - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country=GB' - #'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?lang=en' - - try: f = open('csv/news_settings.json', 'r') all_settings = json.load(f) f.close() - - - - + if all_settings['use_country']: if all_settings['country'] == 'Worldwide': url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news_worldwide?' else: - c_dict = {'United States':'US', 'Australia':'AU', 'Canada': 'CA', 'Great Britain':'GB', 'New Zealand':'NZ', 'Ireland':'IE', 'Singapore':'SG', 'South Africa': 'ZA'} + c_dict = {'United States':'US', 'Australia':'AU', 'Canada': 'CA', 'Great Britain':'GB', 'New Zealand':'NZ', 'Ireland':'IE', 'Singapore':'SG', 'South Africa': 'ZA', 'Germany': 'DE', 'Hong Kong': 'HK', 'Japan': 'JP', 'South Korea': 'KR', 'China': 'CN', 'France': 'FR', 'India': 'IN', 'Italy': 'IT', 'Switzerland': 'CH', 'Netherlands': 'NL', 'Spain': 'ES', 'Brazil': 'BR', 'Portugal': 'PT'} cc = c_dict[all_settings['country']] url = 'https://bm7p954xoh.execute-api.us-east-2.amazonaws.com/default/ScriptsAPI/news?country={}'.format(cc) elif all_settings['use_category']: @@ -547,9 +539,7 @@ def updateNews(api_key, logf): max_headlines = int(all_settings['num_headlines']) #load user settings headlines = data[:max_headlines] - headline_sources = [headline['source'] for headline in headlines] - - + headline_sources = [headline['source'] for headline in headlines] headline_titles = [headline['title'] for headline in headlines] headline_times = [headline['publishedAt'] for headline in headlines]