python automation scripts
python automation scripts
import requests
url = "https://news.ycombinator.com/"
response = requests.get(url)
print(f"{idx}. {item.text}")
import smtplib
def send_email():
email = "[email protected]"
password = "your_password"
recipient = "[email protected]"
msg = EmailMessage()
msg["From"] = email
msg["To"] = recipient
server.login(email, password)
server.send_message(msg)
send_email()
import os
folder_path = "/path/to/folder"
prefix = "file_"
os.rename(old_path, new_path)
import pyttsx3
engine = pyttsx3.init()
engine.runAndWait()
import pywhatkit
🔹 Tip: This will open WhatsApp Web at 2:30 PM and send the message.
6. Download YouTube Videos
url = "https://www.youtube.com/watch?v=your_video_id"
yt = YouTube(url)
yt.streams.get_highest_resolution().download()
print("Download Complete!")
import os
import shutil
folder_path = "/path/to/downloads"
file_types = {
if os.path.isfile(file_path):
if file.endswith(tuple(extensions)):
os.makedirs(new_folder, exist_ok=True)
shutil.move(file_path, new_folder)
print("Files organized successfully!")
import speedtest
st = speedtest.Speedtest()
import requests
url = "https://example.com"
try:
response = requests.get(url)
if response.status_code == 200:
print(f"{url} is UP!")
else:
print(f"{url} is DOWN!")
except requests.ConnectionError:
import os
Fetches the current weather for any city using OpenWeatherMap API.
import requests
API_KEY = "your_api_key"
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric"
response = requests.get(url).json()