Skip to content

ChrisResl/redditMTGCodeScraper

Repository files navigation

redditMTGCodeScraper

A script for detecting redeemable codes posted on the Magic Arena subreddit and sent to your mobile phone

This tool utilizes the Praw framework to scrape the MTG Arena subreddit for redeemable codes that can be used in the game's store. The script is designed to monitor the subreddit every minute and only report codes that have not already been reported that day, as older ones will already be redeemed and are no longer relevant. To automate this process, scheduling is achieved through the use of a cron script.

Setup

  • Create a Telegram bot: https://sendpulse.com/knowledge-base/chatbot/telegram/create-telegram-chatbot
    Note the token.

  • Create a Reddit app under https://www.reddit.com/prefs/apps
    Choose a name (eg. magicbot) and select "script". For "redirect uri" set ```http://localhost:8080``

  • Clone the repository

  • Setup of environment
    conda create -n python=3.11.3 redditMTGCodeScraper pip
    pip install -r requirements.txt

  • In Telegram, initiate a conversation with your bot by typing /start

  • In the telegram_id.py script fill in the token information received upon setup of the Telegram bot and run the script to get chat id

  • Information obtained in the previous two steps will be added to ``send_message_to_telegram()``` in the reddit_scraper.py file

  • Complete the praw.ini file with your reddit account and script information

  • Setup of cron to schedule script
    In terminal: crontab -e
    */1 * * * * cd <path-to-project-directory> && source <path-to-conda-activate-file> <environment-name>; <path-to-conda-python> <path-to-reddit-scraper.py-file>
    Example:
    */1 * * * * cd /home/chris/Workspace/redditMTGCodeScraper && source /home/chris/anaconda3/bin/activate redditMTGCodeScraper; /home/chris/anaconda3/envs/redditMTGCodeScraper/bin/python /home/chris/Workspace/redditMTGCodeScraper/reddit_scraper.py

  • To check if everything is working as intended, a log file was included, reporting at which times the script has been executed.

Dependencies

  • pandas==2.0.1
  • praw==7.7.0
  • Requests==2.29.0

End result

Alt text Alt text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages