-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (40 loc) · 1.52 KB
/
main.py
File metadata and controls
48 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import streamlit as st
from GoogleNews import GoogleNews
from youtube_search import YoutubeSearch
# Set the app to wide mode
st.set_page_config(layout="wide")
# Streamlit app
st.title("Search The Trend")
# Search box
search_query = st.text_input("Enter your search query:")
if search_query:
# Google News Search
googlenews = GoogleNews()
googlenews.search(search_query)
google_results = googlenews.result()
# YouTube Search
youtube_results = YoutubeSearch(search_query, max_results=10).to_dict()
# Display results in columns
col1, col2 = st.columns(2)
with col1:
st.subheader("Google News Results")
if google_results:
for result in google_results:
st.write(f"**Title:** {result['title']}")
st.write(f"**Link:** {result['link']}")
st.write(f"**Description:** {result['desc']}")
st.write('-' * 20)
else:
st.write("No results found on Google News.")
with col2:
st.subheader("YouTube Results")
if youtube_results:
for result in youtube_results:
st.write(f"**Title:** {result['title']}")
st.write(f"**Link:** https://www.youtube.com{result['url_suffix']}")
st.write(f"**Channel:** {result['channel']}")
st.write(f"**Duration:** {result['duration']}")
st.write(f"**Views:** {result['views']}")
st.write('-' * 20)
else:
st.write("No results found on YouTube.")