Skip to content

Instantly share code, notes, and snippets.

@infiniteregrets
Created February 3, 2022 05:18
Show Gist options
  • Save infiniteregrets/965febbc1a5e5054bea0850e33d03723 to your computer and use it in GitHub Desktop.
Save infiniteregrets/965febbc1a5e5054bea0850e33d03723 to your computer and use it in GitHub Desktop.
"""
pip3 install discord-py bs4 aiohttp
- Mehul
"""
import discord
from bs4 import BeautifulSoup
import aiohttp
from discord.ext import commands
bot = commands.Bot(
command_prefix=commands.when_mentioned_or("!"),
intents=discord.Intents.default(),
help_command=None,
)
@bot.event
async def on_ready():
print("Bot is ready!")
@bot.command()
async def pulse(ctx):
async with aiohttp.ClientSession() as session:
payload = {"facilityId": "0986c0ef-0cc6-4659-9f7c-925af22a98c6", "occupancyDisplayType": "00000000-0000-0000-0000-000000004488"}
async with session.post("https://macreconline.ca/FacilityOccupancy/GetFacilityData", data=payload) as r:
res = await r.text()
soup = BeautifulSoup(res, "html.parser")
max_cap = soup.find("p", {"class": "max-occupancy"}).get_text()
occupancy = soup.find("p", {"class": "occupancy-count"}).get_text()
await ctx.send(f"`The current occupancy is {occupancy} out of {max_cap}`")
bot.run("") #your bot token goes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment