cs-newcs-newcs-newcs-new
  • HOME
  • COMPANY
    • ABOUT US
    • LEADERSHIP TEAM
    • PARTNERSHIPS
  • BLOG
  • SERVICES
    • ARTIFICIAL INTELLIGENCE / MACHINE LEARNING
    • BLOCKCHAIN
    • DATA ANALYTICS
    • IOT SOLUTIONS
    • SOFTWARE DEVELOPMENT
    • SOFTWARE TESTING
  • CASE STUDIES
    • ARTIFICIAL INTELLIGENCE / MACHINE LEARNING
    • BLOCKCHAIN
    • DATA ANALYTICS
    • IOT SOLUTIONS
  • GALLERY
    • PHOTOS
    • VIDEOS
    • EVENTS
    • INSPIRATION
  • CAREERS
    • JOIN US
  • CONTACT
Running Multiple Services in a Docker Container via Supervisord at runtime
November 10, 2020
Quantum Computing
November 24, 2020
Published by [email protected] at November 10, 2020
Categories
  • blog
Tags

WhatsApp bot for Auto replying & sending images via Python and Selenium

Author : Anubhav Chaturvedi

Are you the one who wants to send Lots of Quotes or Shayaris to your Ex or to a whatsApp friends or colleague group or random emojis to your wife or Latest gf? This blog will help you out in programming a bot to impress them.
Here comes the demo:
pdf-download
Image for post
Bot performing auto replying and login

For implementing this you will need Jupyter Python notebooks installed .You can use this procedure illustrated over here for installation on windows or Linux :
How To Set Up Jupyter Notebook with Python 3 on Ubuntu 18.04 | DigitalOceanThis tutorial will walk you through setting up Jupyter Notebook to run from an Ubuntu 18.04 server, as well as teach…www.digitalocean.com

Also we will be using Selenium which is an automatic testing tool compatible with Java,Ruby ,Python and many other programming languages.

In order to install the selenium dependencies we will use pip (package installer for python) :

!pip install selenium

!pip install webdriver_manager

For every block to run , we will use Shift+Enter to execute the relevant command.

Along with this you will import the files like this :

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import random
from selenium.webdriver.common.keys import Keys


In order to open Google Chrome from Jupyter notebook automatically we will use “chrome” element as an object from webdriver package and give it relevant URL to open (Web.whatsapp.com for WhatsApp web)
chrome = webdriver.Chrome(ChromeDriverManager().install())
chrome.get

(" https://web.whatsapp.com")

Once you execute this on Jupyter Notebook , you will open this :

WhatsAPP web opened from Jupyter


Once you have the QR code in front of you , scan your whatsApp web and access your WhatsApp account like this:

WhatsApp web after scanned


You will need to access the search contact bar to find contacts for starting a new chat.


You can right click upon it and do “inspect element”

Inspect element



Element class name for Search bar


We can see that class name for the search bar is :”_3FRCZ”

Now we will extract the element using the Python Selenium packages and search for the group named Banglore :

search_box = chrome.find_element_by_class_name(“_3FRCZ”)
search_box.send_keys(“Banglore”)
search_box.send_keys(Keys.ENTER)

Banglore searched and appears on the top


Once “Banglore” appears on the top, we will find its ID again with xpath since Calss and ID’s might create ambiguity:


We will fetch and write a Hello message 10 times using loop in the group:

Code for sending automatic Hello’s ,emotions and images


Similarly , we can give 10 randomly generated emotions in the group

Emotions


Now we can also send attachments as pictures,videos,camera pics or contacts ,by accessing the attachment symbol:

Attachment symbol


Selecting the relevant things to attach


Once you get the xPath of icon photo attachment:

Script to attach the pics:


Sending pics via bot


This is simple packages to autotest the modules created, if you want to implement it kindly refer to the code repository:

For any further Queries or anything related to Blockchain or Devops you can DM me on Linkedin or instagram id=acanubhav94.
Share
2
info@cilans.net
[email protected]

Related posts

December 23, 2020

Up-skilling, Re-skilling, Cross-skilling ….New success mantra for the IT Industry


Read more
November 24, 2020

Quantum Computing


Read more
November 10, 2020

Running Multiple Services in a Docker Container via Supervisord at runtime


Read more

Comments are closed.

About Us

We are a rapidly growing Data Science and software development company. We specialize in AI-ML-DL, Python/R/SPSS, Data Visualization, Blockchain- Hyperledger, IOT and DevOps.

Blog

  • Up-skilling, Re-skilling, Cross-skilling ….New success mantra for the IT Industry
  • Quantum Computing
  • WhatsApp bot for Auto replying & sending images via Python and Selenium

INDIA

501/502 Span Trade Center,
Opposite Kochrab Ashram, Paldi, Ahmedabad , Gujarat , India – 380007.

+91 95588 19097

+91 70431 22287

[email protected]

USA

116 Village Blvd, Suite 200
Princeton, New Jersey 08540, USA.

+1 408 689 1891

[email protected]

© 2020 cilans.net. All Rights Reserved.