Spaces:
Sleeping
Sleeping
File size: 612 Bytes
0fbacc4 35d7624 0fbacc4 |
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 |
import streamlit as st
from dotenv import load_dotenv
from googleapiclient.discovery import build
import os
def main():
load_dotenv()
st.title('Google Search')
query = st.text_input('Search query')
api_key = os.getenv('GOOGLE_SEARCH_API_KEY')
service = build(
"customsearch",
"v1",
developerKey=api_key
)
if ( query ):
results = service.cse().list(
q=query,
cx='05048cc2df6134a06',
).execute()
try:
for item in results['items']:
st.write(item['link'])
except Exception as e:
st.exception(e)
if __name__ == '__main__':
main()
|