Easy Quarantine Meal Prep using Python

Find Saas Video Reviews — it's free
Saas Video Reviews
Personal Care

Easy Quarantine Meal Prep using Python

Table of Contents

  1. Introduction
  2. Script Purpose
  3. Using the Wikipedia API to Retrieve Breakfast Food List
  4. Scraping a Website to Get Lunch Ideas
  5. Extracting Dinner Food Items
  6. Creating a Random Food Generator
  7. Generating a Seven-Day Meal Plan
  8. Emailing the Weekly Meal Plan
  9. Secure Email Credentials
  10. Conclusion


In this article, we will discuss ways to save time when it comes to food. We will explore how to use Python to randomly pick meals for breakfast, lunch, and dinner. Additionally, we will learn how to generate a seven-day meal plan using Python. So, let's dive in and discover how to automate our meal selection process!

Script Purpose

The purpose of the script we will be writing is to randomly select a meal for each mealtime - breakfast, lunch, and dinner. By automating this process, we can save time and avoid the indecision that often comes with meal planning. Furthermore, we will explore how to generate a weekly meal plan using Python.

Using the Wikipedia API to Retrieve Breakfast Food List

To get started, we will utilize the Wikipedia API to retrieve a comprehensive list of breakfast food items. By initializing the Wikipedia API and using the appropriate methods, we can extract the contents of the breakfast page. We will then split the information into sections, with section 0 containing all the breakfast food items. Extracting each food item requires some creative thinking, as the Wikipedia API has certain quirks.

Scraping a Website to Get Lunch Ideas

For obtaining a list of lunch ideas, we will take a different approach. We will scrape a website that provides 52 lunch ideas and extract the HTML using a Python library called Beautiful Soup. By examining the website's structure, we can determine that the food items are located in H3 tags. We will utilize list comprehension to extract the text from these tags, thereby obtaining a list of lunch ideas.

Extracting Dinner Food Items

The process of extracting dinner food items is similar to that of extracting breakfast items. However, the dinner food section contains some unwanted information at the beginning and end. We will apply indexing to filter out the necessary elements from the dinner food list. Once again, we will use the random.choice function to select a random dinner food item.

Creating a Random Food Generator

Now that we have gathered the necessary food lists, we can create a random food generator. The purpose of this generator is to select a random food item corresponding to the user's input for breakfast, lunch, or dinner. We will utilize user input and while loops to ensure correct inputs and generate the random food items. We will also provide an option for the user to start over or exit the program.

Generating a Seven-Day Meal Plan

In addition to the random food generator, we will go a step further and generate a seven-day meal plan. To achieve this, we will create a list of weekdays and a function that cycles through each weekday, selecting a random breakfast, lunch, and dinner item. The generated meal plan will be stored in a list, with each day followed by all three meal types.

Emailing the Weekly Meal Plan

To make the meal planning process even more efficient, we will learn how to email the generated weekly meal plan. Using the smtplib library, we can connect to a Gmail server and send the meal plan via email. Prior to that, we will retrieve email credentials from a secure source. The generated email will have a subject line indicating it is a weekly meal plan and will be structured in a reader-friendly manner.

Secure Email Credentials

To ensure the security of email credentials, we will discuss the best practices for storing them. Instead of reading the credentials from a text file, which may not be secure, we will explore the option of setting them as environment variables on your computer. This method offers more security when running the script and prevents unauthorized access to your email account.


In conclusion, by utilizing Python and various libraries, we can automate the meal planning process, save time, and reduce decision fatigue. With the random food generator and the ability to generate a weekly meal plan, we can easily decide what to eat for breakfast, lunch, and dinner. Additionally, by incorporating email functionality, we can have the meal plan sent directly to our inbox. So why waste time on indecisiveness? Let Python take care of it for you!


  • Automate the meal selection process using Python
  • Randomly pick meals for breakfast, lunch, and dinner
  • Generate a seven-day meal plan with Python
  • Email the weekly meal plan for convenience and accessibility
  • Secure storage of email credentials


Q: Can I customize the meal options for each mealtime? A: Yes, you can modify the food lists used for breakfast, lunch, and dinner. Simply update the lists with your preferred options.

Q: Is this script compatible with other languages? A: Yes, the script can be adapted to work with any language that Wikipedia supports. Just make sure to initialize the Wikipedia API accordingly.

Q: Can I add more meal categories, such as snacks or desserts? A: Absolutely! You can extend the script to include additional meal categories by following a similar approach as the existing meal types.

Q: Is it possible to schedule the weekly meal plan to be sent automatically? A: Yes, you can set up a task scheduler or use a cron job to run the script at a specific time, allowing the email to be sent automatically on a weekly basis.

Q: Can I use my own email provider instead of Gmail? A: Yes, you can modify the code to work with any email provider that supports SMTP. Just make sure to update the necessary server details and port information.

Are you spending too much time on makeup and daily care?

Saas Video Reviews
Personal care

SaasVideoReviews has the world's largest selection of Saas Video Reviews to choose from, and each Saas Video Reviews has a large number of Saas Video Reviews, so you can choose Saas Video Reviews for Saas Video Reviews!

Browse More Content