Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -3,21 +3,21 @@ import requests
|
|
3 |
import bs4
|
4 |
|
5 |
def sitemap(url):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
return out
|
22 |
with gr.Blocks() as app:
|
23 |
inp=gr.Textbox()
|
|
|
3 |
import bs4
|
4 |
|
5 |
def sitemap(url):
|
6 |
+
if url != "" and url != None:
|
7 |
+
out = []
|
8 |
+
source = requests.get(url)
|
9 |
+
if source.status_code ==200:
|
10 |
+
#soup = bs4.BeautifulSoup(source.content,'lxml')
|
11 |
+
soup = bs4.BeautifulSoup(source.content,'html.parser')
|
12 |
+
|
13 |
+
rawp=(f'RAW TEXT RETURNED: {soup.text}')
|
14 |
+
cnt=0
|
15 |
+
cnt+=len(rawp)
|
16 |
+
out.append(rawp)
|
17 |
+
out.append("HTML fragments: ")
|
18 |
+
q=("a","p","span","content","article")
|
19 |
+
for p in soup.find_all("a"):
|
20 |
+
out.append({"LINK TITLE":p.get('title'),"URL":p.get('href'),"STRING":p.string})
|
21 |
return out
|
22 |
with gr.Blocks() as app:
|
23 |
inp=gr.Textbox()
|