Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
from BeautifulSoup import BeautifulSoup | |
import re | |
def search_fn(query): | |
page = requests.get(f"https://www.google.com/search?q={query}") | |
soup = BeautifulSoup(page.content) | |
links = soup.findAll("a") | |
links = soup.findAll("a") | |
for link in soup.find_all("a",href=re.compile("(?<=/url\?q=)(htt.*://.*)")): | |
out = (re.split(":(?=http)",link["href"].replace("/url?q=",""))) | |
print (out) | |
#return out | |
def first(): | |
out = '''<h1>Loading''' | |
return out | |
def test(inp): | |
out = f'''<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
</head> | |
<body> | |
<iframe | |
src="{inp}" | |
frameborder="0" | |
width="100%" | |
height="2000" | |
></iframe> | |
</body> | |
</html>''' | |
return out | |
with gr.Blocks() as app: | |
with gr.Row(): | |
search_box=gr.Textbox("Search") | |
search_btn=gr.Button | |
with gr.Row(): | |
input = gr.Textbox() | |
btn = gr.Button() | |
output = gr.HTML("""""") | |
search_btn.click(search_fn,search_box,None) | |
btn.click(first,None,output).then(test,input,output) | |
app.launch() |