add csv download option
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from google_play_scraper import search
|
3 |
|
4 |
# Streamlit App
|
5 |
def main():
|
6 |
st.title("Google Play App Search")
|
7 |
st.write("Enter a search term to find apps on the Google Play Store.")
|
8 |
-
|
9 |
# Input box for search term
|
10 |
search_term = st.text_input("Search Term", "")
|
11 |
-
|
12 |
if st.button("Search"):
|
13 |
if search_term.strip():
|
14 |
# Fetch apps from the Google Play Store
|
@@ -20,10 +21,26 @@ def main():
|
|
20 |
country="us", # Country
|
21 |
n_hits=300, # Number of results
|
22 |
)
|
23 |
-
|
24 |
# Display results
|
25 |
if results:
|
26 |
st.success(f"Found {len(results)} apps matching '{search_term}':")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
for i, app in enumerate(results, 1):
|
28 |
st.subheader(f"{i}. {app['title']}")
|
29 |
st.write(f"**Developer:** {app['developer']}")
|
@@ -33,11 +50,17 @@ def main():
|
|
33 |
st.image(app['icon'], width=64)
|
34 |
st.write("---")
|
35 |
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
else:
|
39 |
st.warning("No results found.")
|
40 |
-
|
41 |
except Exception as e:
|
42 |
st.error(f"An error occurred: {e}")
|
43 |
else:
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
from google_play_scraper import search
|
4 |
|
5 |
# Streamlit App
|
6 |
def main():
|
7 |
st.title("Google Play App Search")
|
8 |
st.write("Enter a search term to find apps on the Google Play Store.")
|
9 |
+
|
10 |
# Input box for search term
|
11 |
search_term = st.text_input("Search Term", "")
|
12 |
+
|
13 |
if st.button("Search"):
|
14 |
if search_term.strip():
|
15 |
# Fetch apps from the Google Play Store
|
|
|
21 |
country="us", # Country
|
22 |
n_hits=300, # Number of results
|
23 |
)
|
24 |
+
|
25 |
# Display results
|
26 |
if results:
|
27 |
st.success(f"Found {len(results)} apps matching '{search_term}':")
|
28 |
+
|
29 |
+
# Prepare data for display and download
|
30 |
+
data = []
|
31 |
+
for app in results:
|
32 |
+
data.append({
|
33 |
+
"Title": app['title'],
|
34 |
+
"Developer": app['developer'],
|
35 |
+
"Score": app['score'],
|
36 |
+
"App ID": app['appId'],
|
37 |
+
"Link": f"https://play.google.com/store/apps/details?id={app['appId']}"
|
38 |
+
})
|
39 |
+
|
40 |
+
# Convert data to DataFrame
|
41 |
+
df = pd.DataFrame(data)
|
42 |
+
|
43 |
+
# Display apps in the UI
|
44 |
for i, app in enumerate(results, 1):
|
45 |
st.subheader(f"{i}. {app['title']}")
|
46 |
st.write(f"**Developer:** {app['developer']}")
|
|
|
50 |
st.image(app['icon'], width=64)
|
51 |
st.write("---")
|
52 |
|
53 |
+
# Add a download button for CSV
|
54 |
+
csv = df.to_csv(index=False)
|
55 |
+
st.download_button(
|
56 |
+
label="Download results as CSV",
|
57 |
+
data=csv,
|
58 |
+
file_name=f"google_play_apps_{search_term}.csv",
|
59 |
+
mime="text/csv",
|
60 |
+
)
|
61 |
else:
|
62 |
st.warning("No results found.")
|
63 |
+
|
64 |
except Exception as e:
|
65 |
st.error(f"An error occurred: {e}")
|
66 |
else:
|