Calendario de carreras
Calendario de carreras
import requests
from bs4 import BeautifulSoup
def get_athlete_events(name):
url = "https://www.ironman.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# This example assumes the site structure; you'll need to adjust selectors as per actual site structure
results = []
for item in soup.find_all('div', class_='athlete-info'):
athlete_name = item.find('h2').text.strip()
athlete_event = item.find('p', class_='event').text.strip()
if name.lower() in athlete_name.lower():
results.append({'name': athlete_name, 'event': athlete_event})
return results
def create_html(athlete_events):
html_content = """
Athlete Events
"""
with open('athlete_events.html', 'w') as file:
file.write(html_content)
# Example usage
name = "John Doe"
athlete_events = get_athlete_events(name)
create_html(athlete_events)
Events for {name}
-
""".format(name=athlete_events[0]['name'] if athlete_events else 'No athlete found')
for athlete in athlete_events:
html_content += "
- {}: {} ".format(athlete['name'], athlete['event']) html_content += """