home

DISCORD-WEBSCRAPE CHAT BOT

Role Time Frame Tools and Methods
Developer July 2020 Python,
Beautiful Soup,
Discord API

Overview

Discord has become overwhelmingly popular in recent years. It provides an all-in-one experience for users that are interested in gaming and socializing. “Automated programs that look and act like users and automatically respond to events and commands on Discord are called bot users. Discord bot users (or just bots) have nearly unlimited applications.” (Alex Ronquillo, RealPython)

ProblemRepetition

Online shopping can sometimes be hectic. Obtaining the best deals on specific items that are in high demand can be challenging. I wanted to be able to find out prices of different pairs of Converse without having to individually open a tab for each item.
home

Solution"Learning is like collecting seashells."

I built a Discord bot that scrapes data off of the various websites that I am interested in.

1. Webscraping

I learned how to ...
  • use requests and Beautiful Soup for scraping and parsing data from the Web
  • walk through a web scraping pipeline from start to finish
  • build a script that fetches data from the Web and displays relevant information in the console
home
        
        import requests
        from bs4 import BeautifulSoup

        def getDetails(URL):
            page = requests.get(URL).text
            soup = BeautifulSoup(page, 'html.parser')

            model = getModel(soup)
            color = getColor(soup)
            price = getPrice(soup)

            return model + '\n' +  color + '\n' + price
        
      

2. Discord API

I learned how to ...
  • make a Discord bot through the Developer Portal
  • create Discord connections
  • handle events
  • accept commands and validate assumptions
home
        
        @bot.command(name='converse')
        async def conversePrice(ctx):
            
          response = converse.getString()
          await ctx.send(response)
        
      
home