Update app.py
Browse files
app.py
CHANGED
|
@@ -29,39 +29,41 @@ pytrends = TrendReq(hl='en-US', tz=360)
|
|
| 29 |
|
| 30 |
st.title('Google Trends Analyzer')
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
# Data Source selection
|
| 46 |
-
data_source = st.selectbox('Select Data Source:',
|
| 47 |
-
|
| 48 |
|
| 49 |
-
if
|
| 50 |
# Prepare the keywords list
|
| 51 |
-
kw_list = [kw.strip() for kw in
|
| 52 |
-
|
| 53 |
# Convert data source to pytrends parameter
|
| 54 |
gprop_map = {
|
| 55 |
'Web Search': '',
|
| 56 |
'Image Search': 'images',
|
| 57 |
-
'News Search': 'news',
|
| 58 |
-
'Google Shopping': 'froogle',
|
| 59 |
'YouTube Search': 'youtube'
|
| 60 |
}
|
| 61 |
gprop = gprop_map[data_source]
|
| 62 |
|
| 63 |
# Fetch data from Google Trends
|
| 64 |
-
pytrends.build_payload(kw_list, cat=
|
| 65 |
interest_over_time_df = pytrends.interest_over_time()
|
| 66 |
|
| 67 |
if not interest_over_time_df.empty:
|
|
|
|
| 29 |
|
| 30 |
st.title('Google Trends Analyzer')
|
| 31 |
|
| 32 |
+
# Sidebar for options
|
| 33 |
+
with st.sidebar:
|
| 34 |
+
st.header('Analysis Options')
|
| 35 |
|
| 36 |
+
# Input for multiple keywords as separate text boxes
|
| 37 |
+
keyword1 = st.text_input('Enter first keyword to analyze:', 'Streamlit')
|
| 38 |
+
keyword2 = st.text_input('Enter second keyword to analyze (optional):', '')
|
| 39 |
+
keyword3 = st.text_input('Enter third keyword to analyze (optional):', '')
|
| 40 |
|
| 41 |
+
# Geographical focus dropdown
|
| 42 |
+
countries = ['US', 'FR', 'TH', 'DE', 'IN', 'JP', 'BR', 'GB', 'CA', 'AU']
|
| 43 |
+
geo = st.selectbox('Select geographical region:', countries)
|
| 44 |
|
| 45 |
+
# Time range selection
|
| 46 |
+
timeframes = ['now 1-H', 'now 5-H', 'now 1-d', 'now 7-d', 'today 1-m', 'today 3-m']
|
| 47 |
+
timeframe = st.selectbox('Select Time Range:', timeframes)
|
| 48 |
|
| 49 |
+
# Data Source selection limited to specific options
|
| 50 |
+
data_source = st.selectbox('Select Data Source:',
|
| 51 |
+
['Web Search', 'Image Search', 'YouTube Search'])
|
| 52 |
|
| 53 |
+
if keyword1 or keyword2 or keyword3:
|
| 54 |
# Prepare the keywords list
|
| 55 |
+
kw_list = [kw.strip() for kw in [keyword1, keyword2, keyword3] if kw]
|
| 56 |
+
|
| 57 |
# Convert data source to pytrends parameter
|
| 58 |
gprop_map = {
|
| 59 |
'Web Search': '',
|
| 60 |
'Image Search': 'images',
|
|
|
|
|
|
|
| 61 |
'YouTube Search': 'youtube'
|
| 62 |
}
|
| 63 |
gprop = gprop_map[data_source]
|
| 64 |
|
| 65 |
# Fetch data from Google Trends
|
| 66 |
+
pytrends.build_payload(kw_list, cat=0, timeframe=timeframe, geo=geo, gprop=gprop)
|
| 67 |
interest_over_time_df = pytrends.interest_over_time()
|
| 68 |
|
| 69 |
if not interest_over_time_df.empty:
|