TGViewer
پایتون | Data Science | Machine Learning پایتون | Data Science | Machine Learning @python4all_pro · 24.2K subscribers
Post #59 8.21K
🖥 5 useful Python automation scripts

1. Download Youtube videos
pip install pytube

from pytube import YouTube

# Specify the URL of the YouTube video
video_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

# Create a YouTube object
yt = YouTube(video_url)

# Select the highest resolution stream
stream = yt.streams.get_highest_resolution()

# Define the output path for the downloaded video
output_path = "path/to/output/directory/"

# Download the video
stream.download(output_path)

print("Video downloaded successfully!")


2. Automate WhatsApp messages

pip install pywhatkit

import pywhatkit

# Set the target phone number (with country code) and the message
phone_number = "+1234567890"
message = "Hello, this is an automated WhatsApp message!"

# Schedule the message to be sent at a specific time (24-hour format)
hour = 13
minute = 30

# Send the scheduled message
pywhatkit.sendwhatmsg(phone_number, message, hour, minute)

3. Google search with Python

pip install googlesearch-python


from googlesearch import search

# Define the query you want to search
query = "Python programming"

# Specify the number of search results you want to retrieve
num_results = 5

# Perform the search and retrieve the results
search_results = search(query, num_results=num_results, lang='en')

# Print the search results
for result in search_results:
print(result)

4. Download Instagram posts

pip install instaloader

import instaloader

# Create an instance of Instaloader
loader = instaloader.Instaloader()

# Define the target Instagram profile
target_profile = "instagram"

# Download posts from the profile
loader.download_profile(target_profile, profile_pic=False, fast_update=True)

print("Posts downloaded successfully!")


5. Extract audio from video files

pip install moviepy

from moviepy.editor import VideoFileClip

# Define the path to the video file
video_path = "path/to/video/file.mp4"

# Create a VideoFileClip object
video_clip = VideoFileClip(video_path)

# Extract the audio from the video
audio_clip = video_clip.audio

# Define the output audio file path
output_audio_path = "path/to/output/audio/file.mp3"

# Write the audio to the output file
audio_clip.write_audiofile(output_audio_path)

# Close the clips
video_clip.close()
audio_clip.close()

print("Audio extracted successfully!")



#code

کانال آموزش پایتون برای همه ( از صفر تا 100)
👇
🆔 @Python4all_pro
  • 👍 6
  • ❤ 1
  • 🙏 1
  • 🦄 1
More from @python4all_pro
  1. Oct 6, 2026#ایونت_آنلاین مجازی‌سازی؛ قلب پنهان زیرساخت👀 اگه به شبکه، سرور و زیرساخت علاقه داری، احتم…
  2. Oct 6, 2026🔴🔴ماهی 3 پروژه 20 میلیونی این شغل 60 میلیون بهت درآمد میده ۳۰ نفری که در تیم ما استخدام…
  3. Oct 4, 2026‌🔴 خبر فوری — انتخاب رشته هوشمند و رایگان با «مسیر» 🔥 «مسیر» نرم‌افزار هوشمند و کاملاً ر…
  4. Sep 29, 2026What better way to understand a powerful tool like Claude Code than to build your own vers…
  5. Sep 28, 202625 GitHub Repositories Every Python Developer Should Know! Want to improve your Python ski…
  6. Sep 27, 202640+ FREE Python Books from Amazon! Want to improve your Python skills without spending a f…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →