-
-
Save thatrandomperson5/77b3786fbda6fe571e7bd598850561f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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