x-whatsapp by x-cortex is a python library for automating WhatsApp interactions. It uses playwright to automate tasks such as sending messages, fetching chat history, and listening for new messages on WhatsApp Web.
from x_whatsapp import WhatsappClient
# Initialize the client with debugging enabled
client = WhatsappClient(DEBUG=True)
# Initialize Playwright and launch the browser
await client.initialize_playwright()
# Log in to WhatsApp
await client.login()await client.send_message("contact_name", "Hello from x-whatsapp!")await client.open_chat_panel("contact_name")
messages = await client.extract_messages()
for message in messages:
print(message)await client.logout()Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.