Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,13 +23,13 @@ def find_all(url,q=None,num=None):
|
|
23 |
|
24 |
def find_it(url,q=None,num=None):
|
25 |
out = []
|
26 |
-
|
27 |
source = urllib.request.urlopen(url).read()
|
28 |
soup = bs4.BeautifulSoup(source,'lxml')
|
29 |
|
30 |
for p in soup.find_all(f'{q}'):
|
31 |
if num != "":
|
32 |
-
|
33 |
|
34 |
try:
|
35 |
test = soup.select(f'{p.name}:first-child')
|
@@ -38,7 +38,7 @@ def find_it(url,q=None,num=None):
|
|
38 |
except Exception as e:
|
39 |
print (e)
|
40 |
#out.append(p)
|
41 |
-
out.append([{q:p.string,"parent":p.parent.name,"previous":[b for b in p.previous],"first-child":[b.name for b in p.children],"content":p}])
|
42 |
#out.append(p.parent.name)
|
43 |
print(dir(p))
|
44 |
print(p.parent.name)
|
|
|
23 |
|
24 |
def find_it(url,q=None,num=None):
|
25 |
out = []
|
26 |
+
z=""
|
27 |
source = urllib.request.urlopen(url).read()
|
28 |
soup = bs4.BeautifulSoup(source,'lxml')
|
29 |
|
30 |
for p in soup.find_all(f'{q}'):
|
31 |
if num != "":
|
32 |
+
z=p.get(f'{num}')
|
33 |
|
34 |
try:
|
35 |
test = soup.select(f'{p.name}:first-child')
|
|
|
38 |
except Exception as e:
|
39 |
print (e)
|
40 |
#out.append(p)
|
41 |
+
out.append([{q:p.string,"additional":z,"parent":p.parent.name,"previous":[b for b in p.previous],"first-child":[b.name for b in p.children],"content":p}])
|
42 |
#out.append(p.parent.name)
|
43 |
print(dir(p))
|
44 |
print(p.parent.name)
|