Omnibus commited on
Commit
d6afb45
1 Parent(s): 74bf1e0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import urllib.request
3
+
4
+ import bs4
5
+ import lxml
6
+
7
+ def find_it1(url):
8
+ source = urllib.request.urlopen(url).read()
9
+ soup = bs.BeautifulSoup(source,'lxml')
10
+ # title of the page
11
+ print(soup.title)
12
+
13
+ # get attributes:
14
+ print(soup.title.name)
15
+
16
+ # get values:
17
+ print(soup.title.string)
18
+
19
+ # beginning navigation:
20
+ print(soup.title.parent.name)
21
+
22
+ # getting specific values:
23
+ print(soup.p)
24
+ print(soup.find_all('p'))
25
+ for paragraph in soup.find_all('p'):
26
+ print(paragraph.string)
27
+ print(str(paragraph.text))
28
+
29
+ for url in soup.find_all('a'):
30
+ print(url.get('href'))
31
+ print(soup.get_text())
32
+
33
+
34
+
35
+ def find_it2(url):
36
+ response = requests.get(url,a1=None,q2=None,q3=None)
37
+ try:
38
+ response.raise_for_status()
39
+ soup = BeautifulSoup(response.content, 'lxml')
40
+ out = 'URL Links:\n'.join([p.text for p in soup.find_all('a')])
41
+ return out
42
+ except Exception as e:
43
+ print (e)
44
+ return e
45
+
46
+
47
+ with gr.Blocks() as app:
48
+ with gr.Row():
49
+ inp = gr.Textbox()
50
+ btn = gr.Button()
51
+ outp = gr.Textbox()
52
+ btn.click(find_it2,inp,outp)
53
+ app.launc()
54
+