import streamlit as st import pandas as pd from google_play_scraper import search # Streamlit App def main(): st.title("Google Play App Search") st.write("Enter a search term to find apps on the Google Play Store.") # Input box for search term search_term = st.text_input("Search Term", "") if st.button("Search"): if search_term.strip(): # Fetch apps from the Google Play Store st.info("Searching for apps...") try: results = search( search_term, lang="en", # Language country="us", # Country n_hits=300, # Number of results ) # Display results if results: st.success(f"Found {len(results)} apps matching '{search_term}':") # Prepare data for display and download data = [] for app in results: data.append({ "Title": app['title'], "Developer": app['developer'], "Score": app['score'], "App ID": app['appId'], "Link": f"https://play.google.com/store/apps/details?id={app['appId']}" }) # Convert data to DataFrame df = pd.DataFrame(data) # Display apps in the UI for i, app in enumerate(results, 1): st.subheader(f"{i}. {app['title']}") st.write(f"**Developer:** {app['developer']}") st.write(f"**Score:** {app['score']}") st.write(f"**App ID:** {app['appId']}") st.write(f"[Google Play Link](https://play.google.com/store/apps/details?id={app['appId']})") st.image(app['icon'], width=64) st.write("---") # Add a download button for CSV csv = df.to_csv(index=False) st.download_button( label="Download results as CSV", data=csv, file_name=f"google_play_apps_{search_term}.csv", mime="text/csv", ) else: st.warning("No results found.") except Exception as e: st.error(f"An error occurred: {e}") else: st.warning("Please enter a valid search term.") if __name__ == "__main__": main()