Abhlash commited on
Commit
887d8a3
1 Parent(s): 57e6800
Files changed (1) hide show
  1. utils/events.py +30 -0
utils/events.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ from datetime import datetime
4
+
5
+ def get_burning_man_dates():
6
+ current_year = datetime.now().year
7
+ print(f"{current_year} is the current year")
8
+ url = "https://burningman.org/event/"
9
+
10
+ response = requests.get(url)
11
+ if response.status_code == 200:
12
+ soup = BeautifulSoup(response.content, 'html.parser')
13
+
14
+ # Look for the heading that contains the year
15
+ year_heading = soup.find('h1', string=lambda text: str(current_year) in text if text else False)
16
+
17
+ if year_heading:
18
+ # Find the paragraph that follows the year heading
19
+ date_paragraph = year_heading.find_next('p')
20
+ if date_paragraph:
21
+ result = f"Burning Man {current_year}: {date_paragraph.text.strip()}"
22
+ else:
23
+ result = f"Unable to find specific dates for Burning Man {current_year}."
24
+ else:
25
+ result = f"Unable to find information for Burning Man {current_year}."
26
+ else:
27
+ result = "Unable to fetch event dates at the moment."
28
+
29
+ print(result)
30
+ return result