File size: 1,118 Bytes
a728a0a
b17f522
5ba7d4a
b17f522
 
 
 
 
b843a6a
b17f522
 
 
70197c9
82b10de
b843a6a
b17f522
a728a0a
 
5d06996
 
 
 
a728a0a
a137c8a
a728a0a
 
 
 
 
5d06996
a728a0a
 
 
e9a0290
a728a0a
a137c8a
a728a0a
 
b17f522
 
9730688
b17f522
 
 
a728a0a
b17f522
 
7c4cb65
a728a0a
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
import gradio as gr
import requests
from bs4 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=","").split("&sa",1)[0]))
        out = out[0]
        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()