10 Amazing Automation Scripts You Need To Try Using Python:

Python is a popular programming language that is widely used for automation tasks. Here are ten amazing automation scripts that you can try using Python:

  1. Proofreading: Use the Lmproof module to eliminate grammar and spelling mistakes from your writing. Here’s an example code snippet:
# 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")
  1. Playing Random Music: This script randomly picks a song from a folder containing songs and plays it with the help of the OS and random modules in Python. Here’s an example code snippet:
import random, os

music_dir = 'E:\\\\music diretory'
songs = os.listdir(music_dir)
song = random.randint(0,len(songs))

# Prints The Song Name
print(songs[song])

os.startfile(os.path.join(music_dir, songs[0]))
  1. PDF to CSV Converter: Convert pdf data to CSV (comma separated value) data so you can use it for further analysis. Here’s an example code snippet:
import tabula

filename = input("Enter File Path: ")
df = tabula.read_pdf(filename, encoding='utf-8', spreadsheet=True, pages='1')
df.to_csv('output.csv')
  1. Photo Compressor: Decrease the size of a picture by compressing it – while still keeping its quality. Here’s an example code snippet:
import PIL
from PIL import Image
from tkinter.filedialog import *

fl=askopenfilenames()
img = Image.open(fl[0])
img.save("output.jpg", "JPEG", optimize = True, quality = 10)
  1. Automated Email Sender: Send emails automatically using Python. Here’s an example code snippet:
import smtplib

def send_email(subject, msg):
    try:
        server = smtplib.SMTP('smtp.gmail.com:587')
        server.ehlo()
        server.starttls()
        server.login('your_email_address@gmail.com', 'your_email_password')
        message = 'Subject: {}\n\n{}'.format(subject, msg)
        server.sendmail('your_email_address@gmail.com', 'recipient_email_address@gmail.com', message)
        server.quit()
        print("Success: Email sent!")
    except:
        print("Email failed to send.")
  1. Automated Web Scraper: Scrape data from websites automatically using Python. Here’s an example code snippet:
import requests
from bs4 import BeautifulSoup

url = 'https://www.example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

for link in soup.find_all('a'):
    print(link.get('href'))
  1. Automated File Renamer: Rename files automatically using Python. Here’s an example code snippet:
import os

def main():
    i = 0
    path = "C:/Users/Username/Desktop/Folder/"
    for filename in os.listdir(path):
        my_dest = "img" + str(i) + ".jpg"
        my_source = path + filename
        my_dest = path + my_dest
        os.rename(my_source, my_dest)
        i += 1

if __name__ == '__main__':
    main()
  1. Automated Data Backup: Backup data automatically using Python. Here’s an example code snippet:
import shutil

def backup():
    source = 'C:/Users/Username/Desktop/Folder'
    destination = 'D:/Backup/Folder'
    dest = shutil.copytree(source, destination)
    print("Backup successful!")

backup()
  1. Automated Social Media Posting: Post on social media automatically using Python. Here’s an example code snippet:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

class TwitterBot:
    def __init__(self, username, password):
        self.username = username
        self.password = password
        self.bot = webdriver.Firefox()

    def login(self):
        bot = self.bot
        bot.get('https://twitter.com/')
        time.sleep(3)
        email = bot.find_element_by_name('session[username_or_email]')
        password = bot.find_element_by_name('session[password]')
        email.clear()
        password.clear()
        email.send_keys(self.username)
        password.send_keys(self.password)
        password.send_keys(Keys.RETURN)
        time.sleep(3)

    def tweet(self, message):
        bot = self.bot
        bot.get('https://twitter

Comments