Power of python !!!!
In this blog we will read the power of python . Python is very popular language among the world . Python provide many amazing libraries , module etc . Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation via the off-side rule. Python is dynamically typed and garbage-collected.We can email to the anyone , sms to anyone , whatsapp to anyone etc .Even we can built the mini alexa which listen our instructions
1.Python program to whatsapp anyone
pywhatkit is a python module for sending Whatsapp messages at a certain time. To install the pywhatkit module, Type the following command in your IDE/Compiler:
pip install pywhatkit
To use this python library to send messages automatically on WhatsApp at certain times, we need a chrome browser and you must have your WhatsApp logged into the web.whatsapp.com website
The code is following below:
import pywhatkit
pywhatkit.sendwhatmsg("+919045091023",
"Vimal sir rocks !!!",
16, 50)
sendwhatmsg() is the function provided by pywhatkit which takes argument sender_number,message to sent, time in format (hr, min)
2.Python program to email anyone
Python offers a ` library to send emails- “SMTP lib”. “smtplib” creates a Simple Mail Transfer Protocol client session object which is used to send emails to any valid email id on the internet. The Port number used here is ‘587’. And if you want to send mail using a website other than Gmail.
The code are as following below:
# “smtplib” library needs to be imported.
import smtplib
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
#For Gmail, we use port number 587.
# start TLS for security
s.starttls()
# Authentication
s.login("leonardovinci67@gmail.com", "rigluzfqwauroktk")
# message to be sent
message = "Message_you_need_to_send"
# sending the mail
s.sendmail("leonardovinci67@gmail.com", "rajivsecular208@gmail.com", message)
# terminating the session
s.quit()
here we use app code in case of 2-Step Verification.In 2-Step Verification we can’t use password .How to use and create app password
We can use this link
https://support.google.com/mail/answer/185833?hl=en
3.Python program to SMS anyone
If you are running any python script and want to send regular updates from your script to your mobile phone through SMS, you can use twilio API to send SMS.
We use twilio module . It provide Client function which takes keywords key secret , key password . it provides reference or object of class . It has function create() which has argument body, from ,to
account_sid ="ACf974958d207393a17ee86c482b30a2d5"
auth_token = "0ba30655ac380a170f4b9c6794ac8678"
from twilio.rest import Client
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body='Hello there from Twilio SMS API',
from_ = +13184076608,
to = 919773976298
)
print(message.sid)