Automate Your Life: 4 Python Projects to Tackle This Weekend
Written on
Chapter 1: Introduction to Python Automation Projects
Python is renowned for its versatility, especially in the realm of automation. With this powerful language, you can craft solutions that streamline tedious tasks, ultimately saving you countless hours of manual work. Why not devote a weekend to developing a Python bot that handles these repetitive chores for you? Below, I outline several automation projects that can enhance your daily life, categorized from beginner to advanced levels.
Section 1.1: Table Extraction
The first project focuses on extracting tables from PDFs and HTML pages. This task is relatively simple, as the libraries we will utilize handle the most challenging aspects of table extraction.
Initially, we will use the Camelot library to extract tables from PDF documents. While various tools exist for extracting tables without coding, Camelot offers customization options that increase the likelihood of obtaining data in a usable format. For this, you just need a PDF containing a table, like the one shown below.
Next, we will leverage Pandas to extract tables from HTML sources, such as Wikipedia. The Pandas method .read_html efficiently retrieves all tables from a webpage. In the accompanying tutorial, I demonstrate how to extract tables from a Wikipedia page listing all episodes of The Simpsons.
Finally, Pandas can also read CSV files hosted online using the .read_csv method. Although you might typically use .read_csv for local files, it can also access data stored on the web.
Section 1.2: Web Automation for Your Morning News
In this project, we aim to automate the process of gathering morning news. Even if mornings aren’t your favorite time, you might still check headlines on YouTube, news sites, or social media.
Using Python, you can extract these headlines effortlessly! The Selenium library allows for the automation of most websites, enabling you to create a bot that mimics user actions. With Selenium, your bot can click buttons, select dropdown options, fill out forms, and navigate different pages.
The headlines we extract will help you concentrate on the news that interests you, eliminating distractions from those annoying ads that clutter many sites.
In the tutorial linked below, I focus on extracting football headlines, but you are free to choose any news site that appeals to you. Remember, mastering Selenium and constructing an XPath are essential for this project.
Source Code: Automate the News with Python
After completing this project, consider taking on more complex websites, such as:
- WhatsApp Web
- Tinder
Chapter 2: Automate Your Excel Reporting
Generating an Excel report in Python can be as simple as executing a script that produces the report automatically. This project’s goal is to create Excel reports using the Pandas and openpyxl libraries.
Begin with a spreadsheet containing relevant data, which could range from sales figures to sports statistics. Utilize Pandas to create a pivot table, and then apply the openpyxl library to enhance your worksheet with charts, text, and formulas.
In my case, I transformed my Python script into an executable file. Now, I just double-click it, input the corresponding month, and voilà—my report generates automatically.
Guide: A Simple Guide to Automate Your Excel Reporting with Python
Section 2.1: Automating Text Messages
This project unfolds in two phases. The first phase utilizes the pywhatkit library to schedule WhatsApp messages. Pywhatkit simplifies the process of sending messages without the need for elaborate coding.
With pywhatkit, you can use the .sendwhatmsg function for individual contacts and .sendwhatmsg_to_group for group messages.
The second phase involves automating WhatsApp Web using Selenium. While pywhatkit is efficient, Selenium allows for more customized automation, enabling you to send files and images—tasks that pywhatkit may not support.
By the end of this project, you should be capable of sending messages, photos, and files through Python.
Stage 1: Automate WhatsApp Messages with Python in 3 Steps
Stage 2: Automate 99% of Websites with Selenium 4 and Python
Take charge of your life! Join my email list of over 10,000 subscribers to receive your FREE Automation Cheat Sheet.