Spaces:
Sleeping
Sleeping
File size: 773 Bytes
dcaf88f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import streamlit as st
from requests_html import HTMLSession
def perform_search(search_query):
session = HTMLSession()
url = f'https://www.bing.com/search?q={search_query}'
response = session.get(url)
response.html.render(sleep=1)
search_results = response.html.find('li.b_algo')
results = []
for result in search_results:
title = result.find('h2', first=True).text
link = result.find('a', first=True).attrs['href']
results.append(f'{title}\n{link}')
return results
st.title('Web Automation with requests-html')
search_query = st.text_input('Enter a search query')
if st.button('Search'):
results = perform_search(search_query)
st.write('Search Results:')
for result in results:
st.write(result) |