Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,23 +13,33 @@ def convert_into_pd(req_json):
|
|
13 |
result_df = pd.DataFrame(final_json)
|
14 |
return result_df
|
15 |
|
16 |
-
def
|
17 |
-
gewü
|
18 |
for trend_info in req_json:
|
19 |
if trend_info['title'] == gewünschter_titel:
|
20 |
|
21 |
for article in trend_info['articles']:
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def display_articles_for_category(category):
|
27 |
for index, row in real_trending_searches[category].iterrows():
|
28 |
count = index + 1
|
29 |
with st.expander(f"{count}• {row['title']}"):
|
30 |
-
articles =
|
31 |
for count2, url in enumerate(articles, start=1):
|
32 |
-
st.
|
|
|
33 |
|
34 |
categories = {
|
35 |
"Gesundheit": "m",
|
@@ -68,13 +78,12 @@ def check_password():
|
|
68 |
if not check_password():
|
69 |
st.stop() # Do not continue if check_password is not True.
|
70 |
|
71 |
-
|
72 |
pytrend = TrendReq(hl='de-AT', tz=360, timeout=(10,50))
|
73 |
real_trending_searches = {}
|
74 |
base_data = {}
|
75 |
|
76 |
for category_name, category_code in categories.items():
|
77 |
-
base = pytrend.realtime_trending_searches(pn='AT', cat=category_code, count=
|
78 |
base_data[category_name] = base
|
79 |
real_trending_searches[category_name] = convert_into_pd(base)
|
80 |
|
@@ -83,3 +92,4 @@ choices_list = list(real_trending_searches.keys())
|
|
83 |
auswahl = st.selectbox("Select Ressort", choices_list)
|
84 |
|
85 |
display_articles_for_category(auswahl)
|
|
|
|
13 |
result_df = pd.DataFrame(final_json)
|
14 |
return result_df
|
15 |
|
16 |
+
def find_details(req_json, gewünschter_titel):
|
17 |
+
gewünschte_details = []
|
18 |
for trend_info in req_json:
|
19 |
if trend_info['title'] == gewünschter_titel:
|
20 |
|
21 |
for article in trend_info['articles']:
|
22 |
|
23 |
+
article_details = {
|
24 |
+
'url': article['url'],
|
25 |
+
'snippet': article['snippet'],
|
26 |
+
'articleTitle': article['articleTitle'],
|
27 |
+
'time': article['time']
|
28 |
+
}
|
29 |
+
|
30 |
+
gewünschte_details.append(article_details)
|
31 |
+
return gewünschte_details
|
32 |
+
|
33 |
+
|
34 |
|
35 |
def display_articles_for_category(category):
|
36 |
for index, row in real_trending_searches[category].iterrows():
|
37 |
count = index + 1
|
38 |
with st.expander(f"{count}• {row['title']}"):
|
39 |
+
articles = find_details(base_data[category], row['title'])
|
40 |
for count2, url in enumerate(articles, start=1):
|
41 |
+
st.markdown(f"{count2}• {url['articleTitle']} [Go To →]({url['url']})")
|
42 |
+
|
43 |
|
44 |
categories = {
|
45 |
"Gesundheit": "m",
|
|
|
78 |
if not check_password():
|
79 |
st.stop() # Do not continue if check_password is not True.
|
80 |
|
|
|
81 |
pytrend = TrendReq(hl='de-AT', tz=360, timeout=(10,50))
|
82 |
real_trending_searches = {}
|
83 |
base_data = {}
|
84 |
|
85 |
for category_name, category_code in categories.items():
|
86 |
+
base = pytrend.realtime_trending_searches(pn='AT', cat=category_code, count=75)
|
87 |
base_data[category_name] = base
|
88 |
real_trending_searches[category_name] = convert_into_pd(base)
|
89 |
|
|
|
92 |
auswahl = st.selectbox("Select Ressort", choices_list)
|
93 |
|
94 |
display_articles_for_category(auswahl)
|
95 |
+
|