Skip to main content

WhatsApp Web API Wrapper for Chrome, Firefox, Opera, Brave and Edge.

Project description

whapbot_logo PyPI version

WhatsApp Web API Wrapper for Chrome, Firefox, Opera, Brave and Edge.

Installation

pip install pywhapbot

Features

  • Send messages by phone number
  • Store WhatsApp Web sessions in all the browsers. (Edge only available on Windows)
  • Automate the download of Selenium drivers

Simple Usage

from pywhapbot import WhapBot
bot = WhapBot("chrome")  # downloads current driver automatically
bot.log()  # optional
bot.send("+34123456789", "Hello world!")  # forces log
bot.quit()

Download specific drivers automatically

from pywhapbot.install import download_driver
from pywhapbot.utils import get_version

download_driver("firefox", version="0.29.1", root="drivers")
download_driver("opera", version="latest")
download_driver("edge", version="current")

lversion = get_version("brave", "latest")
cversion = get_version("brave", "current")

if cversion < lversion:
    print("You should update your browser to the last version")

More advanced example

from pywhapbot import WhapBot

whapbot = WhapBot(
    browser="firefox",
    driver_path="geckodriver.exe",
    profile_path="profiles/firefox-profile",
    proxy="169.210.345.10:4567",
    kiosk=True  # kiosk mode (not supported on opera)
)
whapmsgs = [("+34696969420", "Open!"),
            ("+34696942069", "Sourcerer!")]

with whapbot as bot:  # Context manager of selenium webdriver class
    bot.get("https://github.com/saizk")
    # Selenium Webdriver command examples
    bot.driver.set_window_position(210, 210)
    assert len(bot.driver.window_handles) == 1 
    bot.driver.find_element_by_link_text("new window").click()
    bot.driver.switch_to.new_window('tab')
    
    for idx, (phone, message) in enumerate(whapmsgs):
        bot.send(phone, message, timeout=15, retries=5)  # forces log
        bot.screenshot(f"whapbot-{idx}.png")
        print(f"{idx+1}/{len(whapmsgs)} messages sent")    

# bot.quit() called by the context manager

Contribute

Would you like to contribute to this project? Here are a few starters:

  • Improve documentation
  • Add Testing examples
  • Bug hunts and refactor
  • Additional features/ More integrations
  • Phantom JS support
  • Implement default browser functions for Mac

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywhapbot-1.0.2.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

pywhapbot-1.0.2-py3-none-any.whl (10.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page