dejanseo commited on
Commit
561915c
·
verified ·
1 Parent(s): 25a1afc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from urllib.parse import urlparse
4
+
5
+ def extract_keywords_from_url(url: str) -> list[str]:
6
+ parsed = urlparse(url)
7
+ path = parsed.path.strip("/")
8
+
9
+ for ext in (".html", ".htm", ".php"):
10
+ if path.endswith(ext):
11
+ path = path[: -len(ext)]
12
+
13
+ cleaned = path.replace("_", " ").replace("-", " ").replace(".", " ")
14
+ segments = cleaned.split("/") if cleaned else []
15
+
16
+ keywords = []
17
+ for seg in segments:
18
+ tokens = seg.split()
19
+ keywords.extend([token.lower() for token in tokens if token.strip()])
20
+ return keywords
21
+
22
+ st.title("🔗 URL Keywords Extractor")
23
+
24
+ urls_input = st.text_area("Enter one or more URLs (one per line):", height=200)
25
+
26
+ if st.button("Extract Keywords"):
27
+ if urls_input.strip():
28
+ urls = [url.strip() for url in urls_input.strip().splitlines() if url.strip()]
29
+ results = [{"URL": url, "Keywords": extract_keywords_from_url(url)} for url in urls]
30
+ df = pd.DataFrame(results)
31
+ st.dataframe(df, use_container_width=True)
32
+ else:
33
+ st.warning("Please enter at least one URL.")