SR05 commited on
Commit
6bd0ca0
·
verified ·
1 Parent(s): a1d4a06

Create abudhabi_visa.py

Browse files
Files changed (1) hide show
  1. abudhabi_visa.py +49 -0
abudhabi_visa.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+ import re
5
+
6
+ URL = "https://www.ireland.ie/en/uae/abudhabi/services/visas/weekly-decision-reports/"
7
+
8
+ def get_latest_report():
9
+ response = requests.get(URL)
10
+ if response.status_code != 200:
11
+ return None, "Failed to fetch the webpage"
12
+
13
+ soup = BeautifulSoup(response.text, "html.parser")
14
+
15
+ # Find all links
16
+ links = soup.find_all("a", href=True)
17
+
18
+ # Regex pattern to match report titles
19
+ pattern = re.compile(r"Abu Dhabi Visa Decision (\d{1,2} \w+ \d{4}) to (\d{1,2} \w+ \d{4})", re.IGNORECASE)
20
+
21
+ latest_date = None
22
+ latest_link = None
23
+ latest_report_name = None
24
+
25
+ for link in links:
26
+ match = pattern.search(link.text)
27
+ if match:
28
+ report_date = match.group(2) # Extract the end date
29
+ if latest_date is None or report_date > latest_date:
30
+ latest_date = report_date
31
+ latest_report_name = link.text.strip()
32
+ latest_link = link['href']
33
+
34
+ if latest_link:
35
+ return latest_report_name, latest_link
36
+ else:
37
+ return None, "No reports found"
38
+
39
+ # Streamlit UI
40
+ st.title("🇦🇪 Abu Dhabi Visa Decision Reports")
41
+ st.write("Fetching the latest visa decision report dynamically.")
42
+
43
+ latest_report, report_url = get_latest_report()
44
+
45
+ if latest_report:
46
+ st.success(f"**Latest Report:** {latest_report}")
47
+ st.markdown(f"[📥 Download Report]({report_url})", unsafe_allow_html=True)
48
+ else:
49
+ st.error(report_url)