All checks were successful
Build and push / changes (push) Successful in 13s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 1m13s
Build and push / sync-argocd-app (push) Successful in 3s
Build and push / post-failure-to-discord (push) Has been skipped
Build and push / post-success-to-discord (push) Successful in 1s
62 lines
1.5 KiB
Python
Executable File
62 lines
1.5 KiB
Python
Executable File
from bs4 import BeautifulSoup
|
|
import pprint
|
|
import requests
|
|
|
|
|
|
pp = pprint.PrettyPrinter(indent=2)
|
|
|
|
url = "https://www.trackpinata.com/"
|
|
|
|
data = {}
|
|
|
|
base_url = "https://www.trackpinata.com"
|
|
|
|
track_url = f"{base_url}/tracks/buttonwillow-circuit"
|
|
response = requests.get(track_url).text
|
|
soup = BeautifulSoup(response, "html.parser")
|
|
|
|
months = soup.find_all("h4", class_="month")
|
|
|
|
for month in months:
|
|
month_name = month.text
|
|
data[month_name] = {"events": []}
|
|
|
|
events = month.find_next(
|
|
"div", class_="collection-list-wrapper w-dyn-list"
|
|
).find_all("a", class_="list-item w-inline-block")
|
|
for event in events:
|
|
data[month_name]["events"].append(
|
|
{
|
|
"reg_url": base_url + event["href"],
|
|
"provider": event.find("div", class_="text-block").text,
|
|
"day": event.find("div", class_="text-block-5").text
|
|
+ " "
|
|
+ month_name
|
|
+ " "
|
|
+ event.find("div", class_="text-block-6").text,
|
|
}
|
|
)
|
|
|
|
# Create a month order mapping
|
|
month_order = {
|
|
"January": 1,
|
|
"February": 2,
|
|
"March": 3,
|
|
"April": 4,
|
|
"May": 5,
|
|
"June": 6,
|
|
"July": 7,
|
|
"August": 8,
|
|
"September": 9,
|
|
"October": 10,
|
|
"November": 11,
|
|
"December": 12,
|
|
}
|
|
|
|
print(soup.find("img", class_="track-map-full")["src"])
|
|
|
|
# for month in sorted(data.keys(), key=lambda x: month_order[x]):
|
|
# print(f"{month}:")
|
|
# pp.pprint(data[month])
|
|
# print()
|