File size: 2,252 Bytes
a728a0a
b17f522
5ba7d4a
b17f522
 
 
 
 
b843a6a
b17f522
 
13a5496
 
b17f522
70197c9
82b10de
72c0de6
ac1d8ed
dacb5fb
13a5496
87e3bbb
b53186f
b843a6a
13a5496
 
cc3d66e
87e3bbb
72c0de6
87e3bbb
a728a0a
 
5d06996
 
 
 
a728a0a
1fbac94
 
8e9b61d
ff29c91
 
d2dde30
ff29c91
17344f2
201d07e
 
390bd6e
 
201d07e
390bd6e
17344f2
 
 
 
 
ba49f41
79734a5
8ac81f0
8d6809c
0cb250a
8d6809c
 
 
5b20fc4
e363e51
8d6809c
 
 
 
 
 
 
 
 
a137c8a
a728a0a
 
 
8e9b61d
 
 
a728a0a
17344f2
1fbac94
17344f2
a728a0a
a137c8a
a728a0a
 
b17f522
 
9730688
72c0de6
b17f522
 
 
a728a0a
b17f522
72c0de6
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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")
    file = open("myfile.txt", "w")

    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]

        frame_l=f'<div class="container-mee"><a class="put-on-top" href="{out}">{out}</a><iframe class="responsive-iframe-mee" src="{out}" frameborder="3"></iframe></div>'
        
        file.writelines(frame_l)
      
        #print(file1.read())
        print (out)
    file.close()
        
    with open("myfile.txt", "r") as file1:
        html_out = file1.read()
        
    return (html_out)


def first():
    out = '''<h1>Loading'''
    return out

def test(inp):
    with open("myfile.txt", "r") as file1:
        html_out = file1.read()
    style = '''
    .put-on-top{
    background: red;
    z-index: 9999;
    }
    .grid-mee {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: space-evenly;
	align-items: stretch;
	align-content: space-evenly;
}

    
    .container-mee {
  
  position: relative;
  overflow: hidden;
  width: 33%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */
  margin-bottom: 2em;
}

/* Then style the iframe to fit in the container div with full height and width */
.responsive-iframe-mee {
  position: relative;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
}

  '''
    out = f'''<!DOCTYPE html>
<html lang="en">
  <head>
  </head>
  <style>
  {style}
  </style>
  <body>
  <div class=grid-mee>
    {html_out}
  </div>
  </body>
</html>'''
    return out
with gr.Blocks() as app:
    with gr.Row():
        search_box=gr.Textbox("Search")
        search_btn=gr.Button()
        out_text = gr.Textbox()
    with gr.Row():
        input = gr.Textbox()
        btn = gr.Button()
    output = gr.HTML("""""")

    search_btn.click(search_fn,search_box,out_text)
    btn.click(first,None,output).then(test,input,output)
app.launch()