Skip to content

Instantly share code, notes, and snippets.

@thatrandomperson5
Last active April 16, 2023 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatrandomperson5/77b3786fbda6fe571e7bd598850561f9 to your computer and use it in GitHub Desktop.
Save thatrandomperson5/77b3786fbda6fe571e7bd598850561f9 to your computer and use it in GitHub Desktop.
import os, discord, asyncio, aiohttp
from discord.ext import commands
from bs4 import BeautifulSoup
intents = discord.Intents.default()
bot = commands.Bot("!", intents=intents)
@bot.event
async def on_ready():
print('Logged in as {0.user}'.format(bot))
bot.session = aiohttp.ClientSession()
@bot.command()
async def stockx(ctx):
url = 'https://stockx.com/de-de/nike-dunk-low-coconut-milk'
async with bot.session.get(url) as response:
content = await response.content.read()
soup = await asyncio.to_thread(BeautifulSoup, content, 'html.parser')
# Find the offers
offers = soup.find_all('div', {'class': 'bid-ask-spread__item'})
for offer in offers:
# Get the bid and ask prices
bid_price = offer.find('div', {'class': 'bid-ask-spread__bid'}).text.strip()
ask_price = offer.find('div', {'class': 'bid-ask-spread__ask'}).text.strip()
# Get the shoe size
shoe_size = offer.find('div', {'class': 'bid-ask-spread__size'}).text.strip()
# Send the data to the Discord channel
await ctx.send(f'Bid: {bid_price}, Ask: {ask_price}, Size: {shoe_size}')
bot.run(os.getenv('DISCORD_TOKEN'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment