WhatsApp Web API Wrapper for Chrome, Firefox, Opera, Brave and Edge.
Project description
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
Release history Release notifications | RSS feed
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.1.tar.gz
(10.5 kB
view details)
Built Distribution
pywhapbot-1.0.1-py3-none-any.whl
(10.5 kB
view details)
File details
Details for the file pywhapbot-1.0.1.tar.gz
.
File metadata
- Download URL: pywhapbot-1.0.1.tar.gz
- Upload date:
- Size: 10.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e076272963b350b3b82a695ffe4cf36c918d9966436f7d8fc5bb7206ca7d3798 |
|
MD5 | c3d1066c747101369d62719db70c2d9c |
|
BLAKE2b-256 | bc6ab031d9fdddba0d1c61160f12fd8288a386fd16ffd02c765ca9a088feecc0 |
File details
Details for the file pywhapbot-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pywhapbot-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cc0ed7cef4e19cd4aae9e0d9e90046623c4ab79e9b2a5a231db4f683686cd80 |
|
MD5 | 57eb5dcc64f296bc6ea8b35cdf925c28 |
|
BLAKE2b-256 | 872875292d7f3fe168a477786d5a3d4b2269673587ce3001d2853114fd8350fe |