query / app.py
Makima57's picture
Upload app.py with huggingface_hub
9827ed6 verified
raw
history blame contribute delete
761 Bytes
# app.py
import streamlit as st
from googlesearch import search
# Function to perform Google search and return the first link
def google_search(query):
# Perform the search and get the first result
search_results = search(query, num_results=1)
first_link = next(search_results, None)
return first_link
# Streamlit app UI
st.title("Search Link Finder")
# Input field for search query
query = st.text_input("Enter search query", "")
# Button to trigger search
if st.button("Search"):
if query:
first_link = google_search(query)
if first_link:
st.success(f"First link: [Click here]({first_link})")
else:
st.warning("No results found")
else:
st.error("Please enter a query")