File size: 2,682 Bytes
f250e40
059dbf4
f250e40
 
 
 
 
 
059dbf4
f250e40
 
059dbf4
f250e40
 
 
 
 
 
 
 
 
 
 
059dbf4
f250e40
 
 
059dbf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f250e40
 
 
 
 
 
 
 
ab58ba3
059dbf4
 
 
 
 
 
 
 
f250e40
 
059dbf4
f250e40
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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()