Scraping the live gym counts at https://connect2concepts.com/connect2/?type=circle&key=2A2BE0D8-DF10-4A48-BEDD-B3BC0CD628E7
Check out husker-nu/husker-gym for the website.
This project scrapes the Connect2Concepts live counts website every 15 minutes using GitHub Actions, and saves the counts to a database. The data is used for https://husker-gym.vercel.app/
Run scrape with
pdm run python -m gymtime -fpdm run db-createpdm run db-drop-all
pdm run db-seed-gyms
pdm run db-seed-test-dataWarning Running
pdm run db-drop-allwill delete all rows in the database. Only run in locally.
Connect to the organization:
pscale org switch husker-gymList all branches:
pscale branch list gymtimeCreating a dev branch for local development:
pscale branch create gymtime devAccess the dev branch of the database with
pscale shell gymtime devThis opens a mysql shell of the branch dev.
Connect to the branch with
pscale connect gymtime devThis makes the dev branch accessible as if it were on localhost.
This needs to be run only once:
pscale connect gymtime main
pdm run db-seed-gymsOnce this is done, confirm the data has been added with
pscale shell gymtime main
show tables;
select * from gym;
select * from section;Add DATABASE_URL to Settings > Secrets and Variables > Actions > Secrets > Repository secrets. Remove the ?sslaccept=strict from the Planetscale URL.
To run all tests, run
pdm run testTests are located in the test/ folder.
(Credits)
from datetime import datetime
# We're using 3.8, but zoneinfo was added in 3.9
from backports.zoneinfo import ZoneInfo
local_tz = ZoneInfo("America/New_York")
utc_tz = ZoneInfo("UTC")
# Boston time
est = datetime(year=2023, month=1, day=15, hour=20, minute=30, second=0)
est = est.replace(tzinfo=local_tz)
# UTC time
utc = est.astimezone(utc_tz)
print(est)
print(utc)- Parth Kabra
- ... (more from Northeastern Electric Racing)