Here are some top Python automation scripts that can simplify everyday tasks:
1. Automate Web Scraping (Extract Data from Websites)
This script fetches the latest news headlines from a website.
import requests
from bs4 import BeautifulSoup
url = "[Link]
response = [Link](url)
soup = BeautifulSoup([Link], "[Link]")
for idx, item in enumerate(soup.find_all("a", class_="storylink")[:5], start=1):
print(f"{idx}. {[Link]}")
2. Automate Sending Emails
Sends an email automatically.
import smtplib
from [Link] import EmailMessage
def send_email():
email = "your_email@[Link]"
password = "your_password"
recipient = "recipient_email@[Link]"
msg = EmailMessage()
msg["Subject"] = "Automated Email"
msg["From"] = email
msg["To"] = recipient
msg.set_content("Hello! This is an automated email.")
with smtplib.SMTP_SSL("[Link]", 465) as server:
[Link](email, password)
server.send_message(msg)
send_email()
print("Email sent successfully!")
🔹 Tip: Use an App Password instead of your Gmail password.
3. Bulk File Renaming
Renames all files in a folder sequentially.
import os
folder_path = "/path/to/folder"
prefix = "file_"
for count, filename in enumerate([Link](folder_path)):
old_path = [Link](folder_path, filename)
new_path = [Link](folder_path, f"{prefix}{count}.txt")
[Link](old_path, new_path)
print("Files renamed successfully!")
4. Convert Text to Speech
Converts text into speech using pyttsx3.
import pyttsx3
engine = [Link]()
[Link]("Hello! This is an automated voice.")
[Link]()
5. Automate WhatsApp Messages
Sends WhatsApp messages using pywhatkit.
import pywhatkit
[Link]("+1234567890", "Hello, this is an automated message!", 14, 30)
🔹 Tip: This will open WhatsApp Web at 2:30 PM and send the message.
6. Download YouTube Videos
Downloads YouTube videos using pytube.
from pytube import YouTube
url = "[Link]
yt = YouTube(url)
[Link].get_highest_resolution().download()
print("Download Complete!")
7. Auto Organize Files
Organizes files into folders based on file type.
import os
import shutil
folder_path = "/path/to/downloads"
file_types = {
"Images": [".jpg", ".jpeg", ".png", ".gif"],
"Documents": [".pdf", ".docx", ".txt"],
"Videos": [".mp4", ".mkv"],
"Music": [".mp3", ".wav"]
for file in [Link](folder_path):
file_path = [Link](folder_path, file)
if [Link](file_path):
for folder, extensions in file_types.items():
if [Link](tuple(extensions)):
new_folder = [Link](folder_path, folder)
[Link](new_folder, exist_ok=True)
[Link](file_path, new_folder)
print("Files organized successfully!")
8. Check Internet Speed
Measures internet speed using speedtest-cli.
import speedtest
st = [Link]()
download_speed = [Link]() / 1_000_000
upload_speed = [Link]() / 1_000_000
print(f"Download Speed: {download_speed:.2f} Mbps")
print(f"Upload Speed: {upload_speed:.2f} Mbps")
9. Automate Website Status Check
Checks if a website is up or down.
import requests
url = "[Link]
try:
response = [Link](url)
if response.status_code == 200:
print(f"{url} is UP!")
else:
print(f"{url} is DOWN!")
except [Link]:
print(f"{url} is NOT REACHABLE!")
10. Auto Shutdown PC
Schedules a shutdown in 60 seconds.
import os
[Link]("shutdown /s /t 60") # Windows
# [Link]("shutdown -h +1") # Linux/Mac (1-minute delay)
11. Get Weather Updates
Fetches the current weather for any city using OpenWeatherMap API.
import requests
API_KEY = "your_api_key"
city = "New York"
url = f"[Link]
response = [Link](url).json()
print(f"Weather in {city}: {response['weather'][0]['description']}, {response['main']['temp']}°C")
🔹 Tip: Get an API key from OpenWeather.
Would you like scripts for any specific use case? 😊