5 More Useful Scripts in Python

5 More Useful Scripts in Python


Published at - Nov 30, 2021

Hello developers, This post is a continuation of the python post. I am here with another 5 important python scripts or mini-projects. I have published part 1 of this post earlier, I will provide the link to that article below.

Python scripts 1–5

5 Most Useful Scripts in Python A list of Python scripts for converting JSON to CSV, generating passwords, searching for strings, fetching links, and…python.plainenglish.io

· 6. Scrap and Download all images from the WEB Page · 7. Battery Notification · 8. Calculate Your Age · 9. Organized download folder with different categories · 10. Send Emails from CSV File

6. Scrap and Download all images from the WEB Page

This script will utilize the selenium and beautifulsoup4 packages to download all photos from a specified webpage.

Installation

  1. We need to install selenium and beautifulsoup4 using pip python package manager pip install selenium beautifulsoup4 .

  2. Then download chrome driver as per your chrome browser version and OS from here — https://chromedriver.chromium.org/

  3. You have to enter the chromedriver path asked by the program.

Python Script

<iframe src="https://medium.com/media/b857f82f7cfc26d6263b8a5dd1fe4b1b" frameborder=0></iframe>

Executing the Script

To run the following script you have to open the terminal into the script’s root directory and need to enter the following command

python3 scrap-img.py

It will ask for the chrome driver path which you have just downloaded and a URL from which you want to download images.

7. Battery Notification

This python script displays a notice regarding the device’s battery percentage.

Installation

To run this script we need to download the psutil, py-notifier, and win10tost by running the following commands.

1. psutil
    > pip install psutil

2. pynotifier
    > pip install py-notifier

3. win10toast
    > pip install win10toast

Python Script

<iframe src="https://medium.com/media/a309334f1136a31647543d51cf9e37fd" frameborder=0></iframe>

Executing the Script

Open your terminal into the root directory of your script file and run the following command

python3 battery.py

8. Calculate Your Age

This script prints your age in three different ways: Years, Months, Days

Python Script

<iframe src="https://medium.com/media/d2ffac14d2962d15a35700d78fe75e7d" frameborder=0></iframe>

Executing the Script

It is quite simple to execute the script!

Simply open a terminal in the folder containing your script and enter the following command:

python3 calculate.py

Then you have to enter the name and age

input your name: XYZ
input your age: 33 
Output - XYZ's age is 33 years or 406 months or 12328 days

9. Organized download folder with different categories

This is a Python script that sorts files in the Download directory into other folders based on their extension.

Python Script

<iframe src="https://medium.com/media/238b74c8959ac102b0c9411cd847d77a" frameborder=0></iframe>

Executing the Script

python3 file-sortor.py

10. Send Emails from CSV File

This project includes a straightforward bulk email script that delivers the same message to a list of recipients.

Installation

This project only requires the Python standard library (more specifically, the csv, email, and smtplib modules).

Python Script

<iframe src="https://medium.com/media/44a576b9fed21dc82a5fdcc1346828cc" frameborder=0></iframe>

Executing the Script

The script necessitates the use of two configuration files:

  • emails.csv should include the email addresses to which the message should be sent.

  • credentials.txt should include your SMTP server login credentials, with your user name and password on separate lines and no extra whitespace or decorations.

The project directory contains two sample files that you will almost certainly desire and need to alter.

Once you’ve got these files in place, all you have to do is

python Send_emails.py

Summary

In this article, I have discussed 5 python scripts or 5 mini-projects that you can create to brush up on your python skills. I hope these will help you learn something new. Clap 👏 on this post to learn more posts from this series of posts soon. Learn more python script posts here.

I hope you enjoyed reading this lesson; you can follow me to read more tutorials from me in the future. Thank you for your time.

By becoming a Medium member, you can support me and your other favorite authors. Thanks! 👇 Join Medium with my referral link - Harendra Verma As a Medium member, a portion of your membership fee goes to writers you read, and you get full access to every story…medium.com

More content at plainenglish.io. Sign up for our free weekly newsletter here.





Follow Us

Follow us on facebook Click Here

Facebook QR
Scan from mobile
Join our telegram channel Click Here
Telegram QR
Scan from mobile