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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file pywhapbot-1.0.2.tar.gz.

File metadata

  • Download URL: pywhapbot-1.0.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for pywhapbot-1.0.2.tar.gz
Algorithm Hash digest
SHA256 54b20a2c5f8d509828a0d0f4908b0f0c21f199321b5b8818f269487d137ff554
MD5 34c403a40eded411abdfa004cffb03de
BLAKE2b-256 c6f486548dbf8f7d8177dd61cd52e70bc6f8ddd9a4cb866e4175514e04bbfa81

See more details on using hashes here.

File details

Details for the file pywhapbot-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pywhapbot-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8

File hashes

Hashes for pywhapbot-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b2d3c463f2acbacd51c78f94268409e83e7b7dea7c1c4fbf4fdac71bede7311
MD5 a589618dcfbf41d230a721bc9e1602fa
BLAKE2b-256 dcf270c29b22d4b78e9964171728bd8d8555c8c5f584766bf382ddc30ff7b39b

See more details on using hashes here.

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