Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,57 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
if
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Streamlit app configuration (must be the first Streamlit command)
|
4 |
+
st.set_page_config(page_title="GDPR Recitals Live Updates", layout="wide")
|
5 |
+
|
6 |
+
import requests
|
7 |
+
from bs4 import BeautifulSoup
|
8 |
+
import legal_document_analysis
|
9 |
+
import up # Import the new up.py module
|
10 |
+
|
11 |
+
# Function to fetch live recitals from the GDPR website
|
12 |
+
def fetch_gdpr_recitals():
|
13 |
+
url = "https://gdpr-info.eu/recitals/"
|
14 |
+
response = requests.get(url)
|
15 |
+
|
16 |
+
# Check if the request was successful
|
17 |
+
if response.status_code != 200:
|
18 |
+
st.error("Update The GDPR website.")
|
19 |
+
return {}
|
20 |
+
|
21 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
22 |
+
|
23 |
+
recitals = {}
|
24 |
+
# Locate all recital links
|
25 |
+
articles = soup.find_all('div', class_='artikel')
|
26 |
+
|
27 |
+
# Extract each recital's link and title
|
28 |
+
for i, article in enumerate(articles):
|
29 |
+
if i >= 3: # Limit to the first 3 recitals
|
30 |
+
break
|
31 |
+
link = article.find('a')['href']
|
32 |
+
number = article.find('span', class_='nummer').text.strip('()')
|
33 |
+
title = article.find('span', class_='titel').text.strip()
|
34 |
+
|
35 |
+
# Fetch the content of each recital
|
36 |
+
rec_response = requests.get(link)
|
37 |
+
if rec_response.status_code == 200:
|
38 |
+
rec_soup = BeautifulSoup(rec_response.content, 'html.parser')
|
39 |
+
content = rec_soup.find('div', class_='entry-content').get_text(strip=True)
|
40 |
+
recitals[number] = {'title': title, 'content': content}
|
41 |
+
else:
|
42 |
+
st.error(f"Failed to fetch recital {number} from {link}")
|
43 |
+
|
44 |
+
return recitals
|
45 |
+
|
46 |
+
# Streamlit App Navigation
|
47 |
+
def main():
|
48 |
+
st.sidebar.title("Navigation")
|
49 |
+
page = st.sidebar.radio("Choose a page", ["Legal Document Analysis", "UP"])
|
50 |
+
|
51 |
+
if page == "Legal Document Analysis":
|
52 |
+
legal_document_analysis.display_legal_analysis_page() # Display the legal analysis page
|
53 |
+
elif page == "UP":
|
54 |
+
up.display_up_page() # Display the UP page
|
55 |
+
|
56 |
+
if __name__ == "__main__":
|
57 |
+
main()
|