Fully automated Chegg Discord bot for "homework help"

Overview

cheggbog

Fully automated Chegg Discord bot for "homework help". Working Sept 15, 2021

Overview

Recently, Chegg has made it extremely difficult to automate retrieval of content from their website. They started using a service called PerimeterX that detects the usage of automation tools like Selenium when accessing the website.

I still wanted to automate the process, so I took it to the extreme with this project. It uses a virtual machine and fake keystrokes to simulate a real user on the website.

Requirements

  • Paid Chegg account (will need to sign in)
  • A decent computer to run the VM
  • Basic Python skills
  • A Discord bot

Step 0: Obtaining the bot and creating the VM

Look up how to create a Discord bot, then add it to any server. It needs the permissions to read messages and add reactions.

For the virtual machine, I am using VMware Workstation 16 Player. It's free and works well. Once it is installed, grab the Media Creation Tool from Microsoft's website, and use it to create a .iso of Windows. Create a new virtual machine using that .iso file, and go through the setup process.

For the VM, click on "I don't have a product key". When it asks you to sign in with a Microsoft account, you can disconnect from the internet, which allows for the creation of a local account and having an empty password. Then, you'll want to install VMware Tools, Chrome, and Python (tested on version 3.9.7). Make sure to check the box to add Python to PATH when installing.

Step 1: Setting up Chrome

The way the bot works is that it opens the URL in Chrome, takes a screenshot of it using the GoFullPage extension by pressing a shortcut for it, then sends that image in the channel where the Chegg link was sent. The tab is also closed and the image is deleted once it is done.

Go to the Chegg website and sign in. Make sure that the device is registered to your account by going to any homework-help link.

Install the GoFullPage extension from the Chrome web store. Right click the icon, go to settings:

  • Set Image format to jpg
  • Set directory to screenshots
  • Check Auto-download files
  • If it asks for permissions, make sure to allow it

Optional (but recommended) tools to improve image output

See below

Install uBlock Origin and add the following as a filter to trim useless page information

! 2021-09-10 https://www.chegg.com
www.chegg.com##.loggedIn.subtype-.type-study.kit-kat-search.force-desktop.chgg-hdr
www.chegg.com##.header-nav.no-subnav.no-nav.chg-body > div > oc-component
www.chegg.com##.sidebar-container
www.chegg.com##.right-sidebar
www.chegg.com##.csrec-cards.csrec-qna

! 2021-09-15 https://www.chegg.com
www.chegg.com###playerpages-right-content
www.chegg.com##.playerpages-right-content.col-3

! 2021-09-23 https://www.chegg.com
www.chegg.com###\35 451367596
www.chegg.com##.csp-content
www.chegg.com##.app-promotion.text-me-app-container

Install Tampermonkey and add the following as a script to improve formatting

// ==UserScript==
// @name         Clean Chegg Website
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  try to take over the world!
// @author       You
// @match        https://www.chegg.com/homework-help/questions-and-answers/*
// @icon         https://www.google.com/s2/favicons?domain=chegg.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.querySelector("div.chg-container.center-content").style.maxWidth = "calc(100% - 13px)";
    document.querySelector("div.chg-container.center-content").style.padding = "0";
    document.querySelector("div.chg-container.center-content").style.margin = "0";
    document.querySelector("div.main-content.question-page").style.width = "calc(100% - 13px)";
    document.getElementById("popup-4").style.paddingBottom = "0";
    document.querySelector("div.chg-footer").style.display = "none";
    document.querySelector('div.txt-2-small.global-breadcrumb').style.display = "none";
    document.querySelector('div.parent-container.question-headline').style.paddingTop = "0";
    document.querySelector('div.parent-container.question-headline').style.paddingBottom = "0";
    document.querySelector('div.main-content.question-page').style.width = "100%";
    document.querySelector('div.chg-content.HomeworkhelpQuestion').style.padding = "0";
    document.querySelector('div.chg-content.HomeworkhelpQuestion').style.minWidth = "unset";
})();

Change the VM resolution to something like 1600x1200 in Display Settings in Windows

In Chrome, set a default resolution by right clicking on the empty space next to the tabs and clicking Size (unsure if this works).

Step 2: Setting up the Discord bot

Download this repository as a zip and extract it to anywhere. Add your bot's private key to key.txt. Open cheggbog.py and edit the variable called "path" with your username.

Open a command prompt in the folder and install the required libraries using the following

python -m pip install -r requirements.txt

Then you can run the bot by typing the following command

python cheggbog.py

Make sure to have at least 1 tab open while the bot is running to improve loading times

Step 3: Testing and final parts

When the bot is running, it is looking for both DMs and messages sent in any channel it can see. Send any Chegg homework help link and make sure not to touch the virtual machine. The intended behavior is the following:

  • Link sent, bot reacts with an emoji to show processing
  • Bot opens link in Chrome, waits for a bit, then triggers the full page screenshot tool
  • After a set amount of time, the bot sends the image in the same channel as the link, closes the Chegg window, and deletes the image file
  • Finally, reacts to the original message to show that it is complete

(Optional) Adding the bot to startup

In the cheggbog folder, create a new file called run.bat with the following contents

python cheggbog.py

Press Win+R and type shell:startup to access the startup programs folder. Create a shortcut to the run.bat file and drop it in this folder, along with a shortcut to Chrome.

(Optional) Adding the VM to startup

On the host computer, go to the location of the VM (default C:\Users[User]\Documents\Virtual Machines[Your VM]). Create a .bat file with the following contents (substitute things in brackets)

"C:\Program Files (x86)\VMware\VMware Player\vmrun" -T player start "C:\Users\[User]\Documents\Virtual Machines\[Your VM]\[Your VM].vmx"

Create a shortcut to this file and place it in the shell:startup folder of the host

Thanks for reading, please leave a star if you found this tool useful, or send me a message if it was useless.

You might also like...
Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google
Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google

Advanced Discord.py Image Bot CREDITS Made by RLX and Mathiscool README by Milrato Installation Guide in .env Adjust the TOKEN python main.py to start

Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Example-bot-discord - Example bot discord xD

example-python-bot-discord Clone this repository Grab a token on Discord's devel

YouTube-Discord-Bot - Discord Bot to Search YouTube
YouTube-Discord-Bot - Discord Bot to Search YouTube

YouTube Bot Info YouTube Bot is a discord bot where you can search for anything

SongLink Discord Bot - Discord bot to share music links easily

SongLink_Discord_Bot Discord bot to share music links easily. Take a link from y

Anime-Discord-Bot - Lightweight anime searching Discord bot supported by the AnilistPython library (anilist.co APIv2 wrapper))
VoiceMaster-Discord-Bot - Fork from original Discord bot with max channel limit, staff role and more

VoiceMaster VoiceMaster is a discord bot created to change the way servers work,

Discord Remote Administration Tool fully written in Python3.

DiscordRAT Discord Remote Administration Tool fully written in Python3. This is a RAT controlled over Discord with over 50 post exploitation modules.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.
A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

Comments
  • Error when running program.

    Error when running program.

    Hi there

    When running the program on Windows Server 2019 with all the tools installed as per the instructions it seems to not run. Attached below is the output.

    `C:\Users\Administrator\Desktop\cheggbog-main>py cheggbog.py Traceback (most recent call last): File "C:\Program Files\Python39\lib\site-packages\discord\http.py", line 300, in static_login data = await self.request(Route('GET', '/users/@me')) File "C:\Program Files\Python39\lib\site-packages\discord\http.py", line 254, in request raise HTTPException(r, data) discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last): File "C:\Users\Administrator\Desktop\cheggbog-main\cheggbog.py", line 59, in client.run(key) File "C:\Program Files\Python39\lib\site-packages\discord\client.py", line 723, in run return future.result() File "C:\Program Files\Python39\lib\site-packages\discord\client.py", line 702, in runner await self.start(*args, **kwargs) File "C:\Program Files\Python39\lib\site-packages\discord\client.py", line 665, in start await self.login(*args, bot=bot) File "C:\Program Files\Python39\lib\site-packages\discord\client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) File "C:\Program Files\Python39\lib\site-packages\discord\http.py", line 304, in static_login raise LoginFailure('Improper token has been passed.') from exc discord.errors.LoginFailure: Improper token has been passed. Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000013F2A7CAE50> Traceback (most recent call last): File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 116, in del self.close() File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

    C:\Users\Administrator\Desktop\cheggbog-main>py cheggbog.py File "C:\Users\Administrator\Desktop\cheggbog-main\cheggbog.py", line 44 path = "C:\Users\Administrator\Downloads\screenshots" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    C:\Users\Administrator\Desktop\cheggbog-main>https://discord.com/api/oauth2/authorize?client_id=896142221424865323&permissions=8&scope=bot 'https:' is not recognized as an internal or external command, operable program or batch file. 'permissions' is not recognized as an internal or external command, operable program or batch file. 'scope' is not recognized as an internal or external command, operable program or batch file.

    C:\Users\Administrator\Desktop\cheggbog-main>py cheggbog.py File "C:\Users\Administrator\Desktop\cheggbog-main\cheggbog.py", line 44 path = "C:\Users\Administrator\Downloads\screenshots" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape`

    Not exactly sure what is causing the error. Thanks!

    opened by Brandonv101 8
Owner
Bryce Hackel
work
Bryce Hackel
You can share your Chegg account for answers using this bot with your friends without getting your account blocked/flagged

Chegg-Answer-Bot You can share your Chegg account for answers using this bot with your friends without getting your account blocked/flagged Reuirement

Ammey Saini 27 Dec 24, 2022
Sunflower-farmers-automated-bot - Sunflower Farmers NFT Game automated bot.IT IS NOT a cheat or hack bot

Sunflower-farmers-auto-bot Sunflower Farmers NFT Game automated bot.IT IS NOT a

Arthur Alves 17 Nov 9, 2022
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
Fully Automated Omegle Chatbot

omegle-bot tutorial features fast runs in background can run multiple instances at once Requirement Run this command in cmd, terminal or PowerShell (i

null 6 Aug 7, 2021
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Arvinth Krishna 12 Aug 31, 2022
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Blue 8 Dec 26, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
An Open-Source Discord bot created to provide basic functionality which should be in every discord guild. We use this same bot with additional configurations for our guilds.

A Discord bot completely written to be taken from the source and built according to your own custom needs. This bot supports some core features and is

Tesseract Coding 14 Jan 11, 2022
Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single bot.

Discord ToolBox Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single b

null 3 Aug 7, 2021
Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

AlexyDaCoder 1 Sep 20, 2022