Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,9 @@ import requests
|
|
4 |
import bs4
|
5 |
import lxml
|
6 |
|
7 |
-
def find_it1(url,
|
8 |
out = []
|
|
|
9 |
source = urllib.request.urlopen(url).read()
|
10 |
soup = bs4.BeautifulSoup(source,'lxml')
|
11 |
# title of the page
|
@@ -23,21 +24,22 @@ def find_it1(url,q1=None,q2=None):
|
|
23 |
# getting specific values:
|
24 |
print(soup.p)
|
25 |
print(soup.find_all('p'))
|
26 |
-
for
|
27 |
-
|
28 |
-
print(paragraph.string)
|
29 |
-
print(str(paragraph.text))
|
30 |
-
out.append(paragraph)
|
31 |
-
out.append(paragraph.string)
|
32 |
-
out.append(paragraph.text)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
for url in soup.find_all('a'):
|
35 |
print(url.get('href'))
|
36 |
|
37 |
print(soup.get_text())
|
38 |
|
39 |
|
40 |
-
return out
|
41 |
|
42 |
def find_it2(url):
|
43 |
response = requests.get(url,a1=None,q2=None,q3=None)
|
@@ -54,8 +56,12 @@ def find_it2(url):
|
|
54 |
with gr.Blocks() as app:
|
55 |
with gr.Row():
|
56 |
inp = gr.Textbox()
|
57 |
-
|
58 |
-
|
59 |
-
btn.
|
|
|
|
|
|
|
|
|
60 |
app.launch()
|
61 |
|
|
|
4 |
import bs4
|
5 |
import lxml
|
6 |
|
7 |
+
def find_it1(url,q=None,num=None):
|
8 |
out = []
|
9 |
+
rawp = []
|
10 |
source = urllib.request.urlopen(url).read()
|
11 |
soup = bs4.BeautifulSoup(source,'lxml')
|
12 |
# title of the page
|
|
|
24 |
# getting specific values:
|
25 |
print(soup.p)
|
26 |
print(soup.find_all('p'))
|
27 |
+
for p in soup.find_all(f'{q}'):
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
#print(paragraph.string)
|
30 |
+
#print(str(paragraph.text))
|
31 |
+
out.append(p)
|
32 |
+
out.append(p.string)
|
33 |
+
out.append(p.text)
|
34 |
+
print([str(tag) for tag in soup.find_all()])
|
35 |
+
rawp.append([str(tag) for tag in soup.find_all])
|
36 |
for url in soup.find_all('a'):
|
37 |
print(url.get('href'))
|
38 |
|
39 |
print(soup.get_text())
|
40 |
|
41 |
|
42 |
+
return rawp, out
|
43 |
|
44 |
def find_it2(url):
|
45 |
response = requests.get(url,a1=None,q2=None,q3=None)
|
|
|
56 |
with gr.Blocks() as app:
|
57 |
with gr.Row():
|
58 |
inp = gr.Textbox()
|
59 |
+
q = gr.Textbox(value="p")
|
60 |
+
num = gr.Number(value=1)
|
61 |
+
btn = gr.Button()
|
62 |
+
with gr.Row():
|
63 |
+
rawp = gr.Textbox()
|
64 |
+
outp = gr.Textbox()
|
65 |
+
btn.click(find_it1,[inp,q,num],[rawp,outp])
|
66 |
app.launch()
|
67 |
|