-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatches.py
30 lines (23 loc) · 1.07 KB
/
matches.py
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
import re
import requests
# Edit URL Link to the RSS Feed Link at the bottom of the matches tab on TBA
# Copy the link that of the button named "Matches in RSS" and should look like this https://www.thebluealliance.com/event/*0000XXXX*/feed
url = 'https://www.thebluealliance.com/event/2023new/feed'
response = requests.get(url)
if response.status_code == 200:
rss_entry = response.text
else:
print("URL Invalid or no matches posted")
exit
# Extract the teams using regular expressions
red_teams = re.findall(r'<li>(\d+)</li>', re.search(r'Red Alliance: -1(.+?)Blue Alliance:', rss_entry, re.DOTALL).group(1))
blue_teams = re.findall(r'<li>(\d+)</li>', re.search(r'Blue Alliance: -1(.+)', rss_entry, re.DOTALL).group(1))
# Print the teams separated by new line
with open('frc.txt', 'a') as f:
for i, team in enumerate(red_teams + blue_teams):
f.write(team + '\n' if (i + 1) % 6 == 0 else team + ' ')
# Print the teams separated by new line, six teams per line
for i, team in enumerate(red_teams + blue_teams):
print(team)
if (i + 1) % 6 == 0:
print('')