All Projects → Fantaso → whatsapp-web

Fantaso / whatsapp-web

Licence: other
Simon is a Python library that helps made easy the browser automation for WhatsApp Web service

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to whatsapp-web

whatsapp-bot
Made with Python and Selenium, can be used to send multiple messages and send messages as characters made of emojis
Stars: ✭ 34 (-49.25%)
Mutual labels:  selenium, whatsapp
whatabomb
A whatsapp bombing GUI Script
Stars: ✭ 84 (+25.37%)
Mutual labels:  selenium, whatsapp
WaWebSessionHandler
(DISCONTINUED) Save WhatsApp Web Sessions as files and open them everywhere!
Stars: ✭ 27 (-59.7%)
Mutual labels:  selenium, whatsapp
tithiwa
Automate Web WhatsApp with selenium in python.
Stars: ✭ 17 (-74.63%)
Mutual labels:  selenium, whatsapp
Whatsappbot
Send messages to any person in any time how much you want.
Stars: ✭ 104 (+55.22%)
Mutual labels:  selenium, whatsapp
Pywhatsapp
Python Automation using selenium & Scheduling of messages and media
Stars: ✭ 257 (+283.58%)
Mutual labels:  selenium, whatsapp
RomanceBreaker
Python script which sends a custom morning message to your significant other every morning at a given time range on Facebook Messenger, WhatsApp, Telegram or SMS, for lazy people
Stars: ✭ 36 (-46.27%)
Mutual labels:  selenium, whatsapp
Whatsapp Assistant Bot
A personal WhatsApp assistant bot that will help you search anything on the web (Google, Images, Google Maps)
Stars: ✭ 198 (+195.52%)
Mutual labels:  selenium, whatsapp
Webwhatsappbot
Core to automatize whatsapp - working 11/2018
Stars: ✭ 59 (-11.94%)
Mutual labels:  selenium, whatsapp
Whalesong
Whalesong is an asyncio python library to manage WebApps remotely. Currently WhatsappWeb is implemented
Stars: ✭ 46 (-31.34%)
Mutual labels:  selenium, whatsapp
Code for fun
Some of my scripts to automate the boring stuff around me
Stars: ✭ 167 (+149.25%)
Mutual labels:  selenium, whatsapp
Whatsapp-Bot
Web.whatsapp.com bot made with selenium
Stars: ✭ 39 (-41.79%)
Mutual labels:  selenium, whatsapp
WeReadScan
扫描“微信读书”已购图书并下载本地PDF的爬虫
Stars: ✭ 273 (+307.46%)
Mutual labels:  selenium
WhatsApp-Bot
🐔 WhatsApp Good Morning
Stars: ✭ 19 (-71.64%)
Mutual labels:  whatsapp
Chatistics
A WhatsApp Chat analyzer and statistics.
Stars: ✭ 32 (-52.24%)
Mutual labels:  whatsapp
robotframework-seleniumtestability
Extension for SeleniumLibrary that provides manual and automatic waiting for asyncronous events like fetch, xhr, etc.
Stars: ✭ 34 (-49.25%)
Mutual labels:  selenium
whatsapp-chat-parser
WhatsApp Chat Parser
Stars: ✭ 13 (-80.6%)
Mutual labels:  whatsapp
docker-selenium-lambda
The simplest demo of chrome automation by python and selenium in AWS Lambda
Stars: ✭ 172 (+156.72%)
Mutual labels:  selenium
TeslaPy
A Python module to use the Tesla Motors Owner API
Stars: ✭ 216 (+222.39%)
Mutual labels:  selenium
basic-selenium-project
an example selenium test project
Stars: ✭ 55 (-17.91%)
Mutual labels:  selenium

Simon, a Python Library for WhatsApp Web Automation

Browser automation for WhatsApp Web service with Python & Selenium.

Project consists to allow a user, with whatsapp installed in their phone, to connect their phone with whatsapp web service https://web.whatsapp.com and to automate the functionalities a user normally performs when using whatsapp as a chat app.

Some functionalities:

  1. Reading messages
  2. Sending messages
  3. Detecting new messages' notifications.
  4. Replying to a specific (making a reference to the message you are replying to) message




Index:

  • Objectives

    • Main Goal & User Story
      • A) detecting new messages
      • B) reading new message(s)
      • C) replying a message
      • D) send a message
  • Installation & Usage

  • Code Examples

    • Login into whatsapp web, check you are logged in & logout
    • Get all opened chats, go into the chat, read the last 10 messages from your friend and reply to the most recent message
    • More examples
  • Information

  • Maintainer




Objectives

Main Goal & User Story

Simon can detect new message(s), read them, analyse it and reply if needed.

A) detecting new messages

  1. get simon_opened_chats
  2. inspect available user from top-bottom for notifications (only on available browser screen view)
  3. click on the opened chat found with a new message notification icon

B) reading new message(s)

  1. get contact_chat
  2. find "n unread messages" section
  3. get first unread msg
  4. read and analyse msg

C) replying a message

  1. get(hover) the reply icon (on the right-side of the message)
  2. click on the reply icon
  3. get the reply link("Reply")
  4. click the reply link (on browser: it puts cursor on the contact_send_message[message_field])

D) send a message

  1. get contact_send_message
  2. write message
  3. press enter to send msg.

Installation & Usage

Install by simple typing pip install whatsapp-web and in your python file you can use it import simon

Code Examples

For the library we are using the Page Pattern recommended by the selenium python library.

Login into whatsapp web, check you are logged in & logout

import time

from selenium import webdriver

from simon.accounts.pages import LoginPage
from simon.header.pages import HeaderPage
from simon.pages import BasePage

# Creating the driver (browser)
driver = webdriver.Firefox()
driver.maximize_window()

# 1. Login
#       and uncheck the remember check box
#       (Get your phone ready to read the QR code)
login_page = LoginPage(driver)
login_page.load()
login_page.remember_me = False
time.sleep(7)


# 2. The base page is inherited by all pages
#       and here you can check whether any
#       page is available on the screen of
#       the browser.

# we don't need to load the pages as whatsapp
# web works as one-page web app
base_page = BasePage(driver)
base_page.is_title_matches()
base_page.is_welcome_page_available()
base_page.is_nav_bar_page_available()
base_page.is_search_page_available()
base_page.is_pane_page_available()
# chat is only available after you open one
base_page.is_chat_page_available()


# 3. Logout
header_page = HeaderPage(driver)
header_page.logout()

# Close the browser
driver.quit()

Get all opened chats, go into the chat, read the last 10 messages from your friend and reply to the most recent message

import time

from selenium import webdriver

from simon.accounts.pages import LoginPage
from simon.chat.pages import ChatPage
from simon.chats.pages import PanePage
from simon.header.pages import HeaderPage


# Creating the driver (browser)
driver = webdriver.Firefox()
driver.maximize_window()

# Login
#       and uncheck the remember check box
#       (Get your phone ready to read the QR code)
login_page = LoginPage(driver)
login_page.load()
time.sleep(7)


# 1. Get all opened chats
#       opened chats are the one chats or conversations
#       you already have in your whatsapp.
#       IT WONT work if you are looking for a contact
#       you have never started a conversation.
pane_page = PanePage(driver)

# get all chats
opened_chats = pane_page.opened_chats

# iterating over them
for oc in opened_chats:
    print(oc.name)  # contact name (as appears on your whatsapp)
    print(oc.icon)  # the url of the image
    print(oc.last_message)
    print(oc.last_message_time)  # datetime object
    print(oc.has_notifications())  # are there unread messages?
    print(oc.notifications)  # returns a integer with the qty of new messages, if there are.


# 2. Go into the chat
#       just click on one to open the chat page
#       (where the conversation is happening)
first_chat = opened_chats[0]
first_chat.click()

# 3. Read the last 10 messages from your contact
chat_page = ChatPage(driver)
msgs = chat_page.messages.newest(10, filterby='contact')

for msg in msgs:
    print(msg.contact) # name (all should be the same)
    print(msg.date)
    print(msg.text)
    print(msg.status)


# 4. Reply to the most recent message
msg = msgs[0]  # get the first of the messages query done in previous step
msg = chat_page.messages.newest(filterby='contact')
# Be careful as library can only now reply to text message
# Replying to a msg type (video, image, giff, etc) is not implemented yet. 
msg.reply("This a reply to a specific text msg.")


# Logout
header_page = HeaderPage(driver)
header_page.logout()

# Close the browser
driver.quit()

More examples

For more functionalities that is offered by the library please check the tests. Here a couple:

Note: If you will try to run the test yourself locally, some of them won't work as some tests are done offline with some html templates that are not available in the repo


Information:

Technology Stack
Python language Language
Selenium selenium Browser Automation
Whatsapp Web whatsapp Chat Service



Maintainer

Get in touch -–> fantaso

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].