Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
|
5 |
+
# Funktion, um alle URLs von einer Webseite zu extrahieren
|
6 |
+
def extract_urls(url):
|
7 |
+
try:
|
8 |
+
response = requests.get(url)
|
9 |
+
response.raise_for_status()
|
10 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
11 |
+
links = [a.get('href') for a in soup.find_all('a', href=True)]
|
12 |
+
return links
|
13 |
+
except Exception as e:
|
14 |
+
return str(e)
|
15 |
+
|
16 |
+
# Streamlit App
|
17 |
+
st.title("Webseiten-URL-Extraktor")
|
18 |
+
|
19 |
+
# Eingabefeld für die URL
|
20 |
+
url_input = st.text_input("Gib die URL der Webseite ein:", placeholder="https://example.com")
|
21 |
+
|
22 |
+
# Wenn der Nutzer eine URL eingibt und auf den Button klickt
|
23 |
+
if st.button("URLs extrahieren"):
|
24 |
+
if url_input:
|
25 |
+
st.write(f"Extrahiere URLs von: {url_input}")
|
26 |
+
urls = extract_urls(url_input)
|