10 Python Mini Automation Projects
Collection of mini projects that will automate your problems
Make your tasks automated by building the mini automation projects that put your repeated task and work on autopilot. In this article, I will show you 10 Python mini-automation projects with code. So mark this article and let's get started.
The age of automation is going to be the age of “do it yourself”.
— Marshall Mcluhen
👉Email Sender
Email is always the best way of marketing and communicating professionally. Now you can send Emails programmatically with Python. This awesome Mini project uses the Yagmail module that will show you how to send an email on any mail server.
# Send Email with Python
# pip install yagmail
from yagmail import SMTP
def Email_Sender(subject, body):
mail = SMTP(user='username', password='password')
mail.send("[email protected]", subject = subject, contents = body)
mail.close()
print("Email Sent")
def Email_With_Attachment(subject, attachment):
mail = SMTP(user='username', password='password')
mail.send("[email protected]", subject = subject, attachments = attachment)
print("Email Sent")
# main
Email_Sender("Subject101", "Hello from Medium")
Email_With_Attachment("Subject102", ["img1.png", "img2.png"])
👉 PDF To Audiobook
Need to convert your PDF To an audiobook then here is a mini project that uses the Google text-to-speech Api and PyPDF4 module to convert all pages of your pdf to an audiobook.
# PDF to Audiobook
# pip install PyPDF4
# pip install gTTS
from PyPDF4 import PdfFileReader
from gtts import gTTS
def Pdf_to_Audio(file_name):
pdf = PdfFileReader(file_name)
for page in range(pdf.getNumPages()):
text = pdf.getPage(page).extractText()
tts = gTTS(text=text, lang='en')
tts.save(f"{page}.mp3")
Pdf_to_Audio("book.pdf")
👉 Weather App
This mini project will automate your Weather forecasting task. You can fetch weather information like temperature, humidity and etc by using the below project code. Explore the API to improve your project more or add new functionalities.
# Weather App
# Get Your Free API : http://openweathermap.org/appid
# pip install requests
import requests as req
from bs4 import BeautifulSoup as bs
def get_weather(loc):
# Set API
key = "Api key"
api_url = f"http://api.openweathermap.org/data/2.5/weather?"
params = f"q={loc}&appid={key}"
# Get the response from the API
url = api_url + params
response = req.get(url)
weather = response.json()
# Fetch Weather
print(f"Weather for {loc}:")
temp = weather['main']['temp']
print("Temperature:", temp - 273.15, "Celsius")
humidity = weather['main']['humidity']
print("Humidity:", humidity, "%")
wind = weather['wind']['speed']
print("Wind speed:", wind, "m/s")
# main
get_weather('London')
👉 Youtube downloader
Create your own youtube downloader by using the Pytube module. Below you can find mini project codes that download videos from youtube URLs in any format.
# Proofreading Tool
# pip install pytube
from pytube import YouTube
import os
def downloader(url):
yt_vid = YouTube(url).streams.filter(progressive=True)
yt_vid.order_by('resolution').desc().first().download()
print("video downloaded")
downloader("youtube.com/watch?v=id")
👉 Excel Data Entry
Data entry is always costly work to do but now you can automate your data entry in excel with this below mini project. It uses the Openpyxl module that allows you to write and format an excel file with few lines of code.
# Excel Data Entry
# pip install openpyxl
from openpyxl import Workbook
from openpyxl.styles import *
# Set up workbook
book = Workbook("excel.xlsx")
pyexcel = book.active
# Set up header
pyexcel.append(["Name", "Job Desc", "Salary"])
# Write by rows
pyexcel.append(["John", "JS Programmer", "$100,000"])
pyexcel.append(["Jane", "Py Programmer", "$150,000"])
# Write by columns
pyexcel["A1"] = "John"
pyexcel["B1"] = "JS Programmer"
pyexcel["C1"] = "$100,000"
# Write by cell
pyexcel.cell(row=1, column=1).value = "John"
pyexcel.cell(row=1, column=2).value = "JS Programmer"
# Format cell
pyexcel.cell(row=1, column=1).font = Font(bold=True)
# save workbook
book.save("excel.xlsx")
👉 Python Proofreading
Want to make your text Grammer and Spell errors Free then try this mini project that uses the Lmproof module. You can explore the module to expand the functionality of the project.
# Python Proofreading
# pip install lmproof
import lmproof
def proofread(text):
proofread = lmproof.load("en")
correction = proofread.proofread(text)
print("Original: {}".format(text))
print("Correction: {}".format(correction))
proofread("Your Text")
👉 Compress Folders and Files
Having files and folders with large sizes then use this mini automation project to compress your folders and files into lower sizes. This project is based on making the zip compress of your files and folder.
# Compress folders and files
import zipfile as zf
import os
# compress files
def compress_files(files):
with zf.ZipFile("compress", 'w') as myzip:
for file in files:
myzip.write(file)
# compress folders
def compress_folders(folders):
with zf.ZipFile("compress", 'w') as myzip:
for folder in folders:
for root, dirs, files in os.walk(folder):
for file in files:
myzip.write(os.path.join(root, file))
# main
compress_files(["video1.mp4", "video2.mp4"])
compress_folders(["folder1", "folder2"])
👉 Internet Speed Tester
Test your internet speed and ping with the OOKLA speed test API. This mini automation project will test your download, and upload speed and also calculate the ping.
# Internet Speed tester
# pip install speedtest-cli
import speedtest as st
# Set Best Server
server = st.Speedtest()
server.get_best_server()
# Test Download Speed
down = server.download()
down = down / 1000000
print(f"Download Speed: {down} Mb/s")
# Test Upload Speed
up = server.upload()
up = up / 1000000
print(f"Upload Speed: {up} Mb/s")
# Test Ping
ping = server.results.ping
print(f"Ping Speed: {ping}")
👉 Web Blocker
Build a Web blocker project in Python by using the below automation project. This project uses the host file that holds the IP and hostname of the website. If you block a website with the below project the website will always redirect 127.0.0.1.
# Block Websites
import os
import sys
host = "C:\Windows\System32\drivers\etc\hosts"
def block_websites(websites):
with open(host, "a") as f:
f.write("\n127.0.0.1 " + websites)
f.close()
def unblock_websites(website):
with open(host, "r") as f:
lines = f.readlines()
f.close()
with open(host, "w") as f:
for line in lines:
if websites not in line:
f.write(line)
f.close()
block_websites(["www.google.com", "www.medium.com"])
👉 Automate Desktop and Web
This mini project will let you automate your desktop apps and website. The project uses the Selenium module which is basically for automating the websites and Pyautogui for automating desktop apps.
# Automate Web and Desktop
# pip install selenium
# pip install webdrivermanager
# pip install pyautogui
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import pyautogui as pag
# <=== Automate Web ===>
google = webdriver.Chrome(ChromeDriverManager().install())
# open webpage
google.get('https://www.google.com')
# Search element
search = google.find_element(By.NAME, 'q')
search = google.find_element(By.TAG_NAME, 'input')
search = google.find_element(By.ID, 'lst-ib')
search = google.find_element(By.CLASS_NAME, 'gsfi')
search = google.find_element(By.CSS_SELECTOR, 'input[name="q"]')
search = google.find_element(By.XPATH, '//input[id="lst-ib"]')
# Click on Element
search.click()
# Send Keys or Type
search.send_keys('Hello World')
search.send_keys(Keys.ENTER)
# <=== Automate Desktop ===>
# Mouse movement
pag.moveTo(5, 5)
pag.moveRel(5, 5)
pag.dragTo(5, 5)
# Mouse clicks
pag.click(5, 5)
pag.doubleClick(5, 5)
pag.rightClick(5, 5)
pag.scroll(5, 5, vertical=True)
# Keyboard Typing
pag.typewrite('Hello World', interval=0.25)
pag.press('enter')
pag.hotkey('ctrl', 'c')
👉 Final Thoughts
Thank you for giving your valuable time to read this article. I hope you find this article helpful and fun to read. If you love this article then Share ❤️ it with your friends because sharing is caring.
Happy Python Coding
Become a member of medium to unlock my all Articles and thousands of other writers’ articles. Sign up for membership for the medium it only costs $5 and also I will receive the small portion that I will use to get Coffee.
You can support me and others by becoming a Member of Medium Thanks! 👇
Never stop learning, Here is your daily dose of my programming articles below, hope you like them also.
More content at PlainEnglish.io. Sign up for our free weekly newsletter. Follow us on Twitter, LinkedIn, YouTube, and Discord.