Skip to content

Commit

Permalink
Add frc practice match yoinker
Browse files Browse the repository at this point in the history
  • Loading branch information
Astatin3 committed Feb 29, 2024
1 parent 25c2694 commit 69d3b49
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tools/practice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import jsonpack as jp
import requests

year = "2024"
matchid = "FLWP"
url = f'https://frc-events.firstinspires.org/{year}/{matchid}/practice'

r = requests.get(url)

data = r.text

data = data.split('<tbody id="match-results" style="white-space: nowrap">')[1]
data = data.split('</tbody>')[0]
data = data.split('<td class="text-start col-2">')
del data[0]

matchIndex = 1

arr = []

for m in data:
teamList = m.split("<a ")
del teamList[0]
teamIndex = 0

red = []
blue = []

for a in teamList:
a = a.split('</a>')[0]
a = a.split('>')[1]
a = a.split('\n')[0]
a = "frc" + a

if teamIndex < 3:
red.append(a)
else:
blue.append(a)

teamIndex += 1

arr.append({
"key": "2024" + matchid.lower() + "_pm" + str(matchIndex),
"red": red,
"blue": blue
})

matchIndex += 1

print(jp.pack(arr))

0 comments on commit 69d3b49

Please sign in to comment.