File size: 1,129 Bytes
887d8a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
from bs4 import BeautifulSoup
from datetime import datetime

def get_burning_man_dates():
    current_year = datetime.now().year
    print(f"{current_year} is the current year")
    url = "https://burningman.org/event/"
    
    response = requests.get(url)
    if response.status_code == 200:
        soup = BeautifulSoup(response.content, 'html.parser')
        
        # Look for the heading that contains the year
        year_heading = soup.find('h1', string=lambda text: str(current_year) in text if text else False)
        
        if year_heading:
            # Find the paragraph that follows the year heading
            date_paragraph = year_heading.find_next('p')
            if date_paragraph:
                result = f"Burning Man {current_year}: {date_paragraph.text.strip()}"
            else:
                result = f"Unable to find specific dates for Burning Man {current_year}."
        else:
            result = f"Unable to find information for Burning Man {current_year}."
    else:
        result = "Unable to fetch event dates at the moment."
    
    print(result)
    return result