Giter Site home page Giter Site logo

inforkgodara / whatsapp-bulk-messages-without-saving-contacts Goto Github PK

View Code? Open in Web Editor NEW
117.0 5.0 52.0 53 KB

It is a python script that sends WhatsApp messages automatically from the WhatsApp web application without saved contact numbers.

Home Page: https://www.youtube.com/@inforkgodara

License: MIT License

Python 100.00%
whatsapp whatsapp-bot whatsapp-automation whatsapp-auto-messaging automation python-automation whatsapp-web python whatsapp-bulk-sender whatsapp-bulk-messages

whatsapp-bulk-messages-without-saving-contacts's Introduction

WhatsApp Bulk Messages Without Saving Contacts

It is a python script that sends WhatsApp message automatically from WhatsApp web application without saved contact numbers. It can be configured to send advertising messages to recipients. It read data from an excel sheet and send a configured message to people.

Contact me over Telegram: https://t.me/inforkgodara

Important Note

  • WhatsApp Business released API on May 2022, no longer needed this repository. You can accomplish your same requirements through WhatsApp Business APIs.

Prerequisites

In order to run the python script, your system must have the following programs/packages installed and the contact number not need to be saved in your phone (You can use bulk contact number saving procedure of email). It has limitation of sending attachment but you can refer to my another repo which has functionality to send document file like pdf, image, etc.

  • Python 3.8: Download it from https://www.python.org/downloads
  • Chrome v79: Download it from https://chrome.google.com
  • Pandas : Run in command prompt pip install pandas
  • Xlrd : Run in command prompt pip install xlrd
  • Selenium: Run in command prompt pip install selenium
  • Web Driver: Run in command prompt pip install webdriver_manager
  • Openpyxl: Run in command prompt pip install openpyxl

Approach

  • First need to clone this respiratory
  • Run python script script.py using py script.py in the terminal
  • The script opens WhatsApp web using chrome.
  • User needs to scan QR code from his/her phone.
  • Enter in command prompt to execute further.
  • The script hit url with contact number and message from excel sheet.
  • Once all the message will be sent chrome driver will automatically closed.

Note: If you wish to send an image instead of text you can write attachment selection python code.

Legal

  • This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk. Commercial use of this code/repo is strictly prohibited.

Code

# Program to send bulk messages through WhatsApp web from an excel sheet without saving contact numbers
# Author @inforkgodara

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from time import sleep
import pandas

excel_data = pandas.read_excel('Recipients data.xlsx', sheet_name='Recipients')

count = 0

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://web.whatsapp.com')
input("Press ENTER after login into Whatsapp Web and your chats are visiable.")
for column in excel_data['Contact'].tolist():
    try:
        url = 'https://web.whatsapp.com/send?phone=' + str(excel_data['Contact'][count]) 
        + '&text=' + excel_data['Message'][0]
        sent = False
        # It tries 3 times to send a message in case if there any error occurred
        driver.get(url)
        try:
            click_btn = WebDriverWait(driver, 35).until(
                EC.element_to_be_clickable((By.CLASS_NAME, '_3XKXx')))
        except Exception as e:
            print("Sorry message could not sent to " + str(excel_data['Contact'][count]))
        else:
            sleep(2)
            click_btn.click()
            sent = True
            sleep(5)
            print('Message sent to: ' + str(excel_data['Contact'][count]))
        count = count + 1
    except Exception as e:
        print('Failed to send message to ' + str(excel_data['Contact'][count]) + str(e))
driver.quit()
print("The script executed successfully.")

Note: The script may not work in case if the HTML of web WhatsApp is changed. If you face any problem please do let me know. Surely I will help you out. You can expect response on weekend only others days extremely busy with my routine activities.

whatsapp-bulk-messages-without-saving-contacts's People

Contributors

gifa01 avatar iamimmanuelraj avatar inforkgodara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

whatsapp-bulk-messages-without-saving-contacts's Issues

Very slow and fails

The script needs improvements it fails to send a message too much and is very slow.

doubt

By.CLASS_NAME, '_3XKXx' what it meant by??

message is not sending

i'm really impress your project now i need your help "Sorry message could not sent to 9995777882
Sorry message could not sent to 33999999999" actually this script execute like this but my number is real how to resolve this
[email protected] my gmail frnd.

Account got banned

whatsapp flagged the messages as spam and banned the account after just 3 messages sent, is there a way to prevent this? would adding a delay help?

error

this message show up when i runn
Traceback (most recent call last):
File "C:\Users\ahlam\PycharmProjects\pythonProject\Data analyst\whatsup\whats.py", line 12, in
excel_data = pandas.read_excel('Recipients data.xlsx', sheet_name='Recipients')
File "C:\Users\ahlam\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\io\excel_base.py", line 478, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "C:\Users\ahlam\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\io\excel_base.py", line 1496, in init
ext = inspect_excel_format(
File "C:\Users\ahlam\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\io\excel_base.py", line 1371, in inspect_excel_format
with get_handle(
File "C:\Users\ahlam\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\io\common.py", line 868, in get_handle
handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'Recipients data.xlsx'

Images

How can we send images too along with messages?

Suggestion

After sending the message to the contact, need to delete the message for me.
search the contact from the search box and send the message along with the above functionality

certificate verify failed: unable to get local issuer certificate

Showing certificate related issue

`====== WebDriver manager ======
Current google-chrome version is 99.0.4844
Get LATEST chromedriver version for 99.0.4844 google-chrome
Traceback (most recent call last):
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Program Files\Python38\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Program Files\Python38\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Program Files\Python38\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\urllib3\util\retry.py", line 573, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='chromedriver.storage.googleapis.com', port=443): Max retries exceeded with url: /LATEST_RELEASE_99.0.4844 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Dipen.Parmar\Downloads\whatsapp-bulk-messages-without-saving-contacts\script.py", line 16, in <module>
    driver = webdriver.Chrome(ChromeDriverManager().install())
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\chrome.py", line 32, in install
    driver_path = self._get_driver_path(self.driver)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\manager.py", line 19, in _get_driver_path
    binary_path = self.driver_cache.find_driver(driver)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\driver_cache.py", line 74, in find_driver
    driver_version = driver.get_version()
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\driver.py", line 39, in get_version
    self.get_latest_release_version()
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\driver.py", line 72, in get_latest_release_version
    resp = requests.get(
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Dipen.Parmar\AppData\Roaming\Python\Python38\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='chromedriver.storage.googleapis.com', port=443): Max retries exceeded with url: /LATEST_RELEASE_99.0.4844 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)')))`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.