{"id":22840852,"url":"https://github.com/kazedevid/wwebpy","last_synced_at":"2025-03-31T04:37:18.506Z","repository":{"id":264511897,"uuid":"627787796","full_name":"KazeDevID/wwebpy","owner":"KazeDevID","description":"wwebpy, a Python Library for WhatsApp Web Automation","archived":false,"fork":false,"pushed_at":"2023-04-14T12:45:55.000Z","size":66,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T09:13:59.270Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KazeDevID.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-14T07:47:11.000Z","updated_at":"2023-06-17T22:33:21.000Z","dependencies_parsed_at":"2024-11-24T20:08:21.237Z","dependency_job_id":"38ba723f-c6b0-453b-ab97-021f58575933","html_url":"https://github.com/KazeDevID/wwebpy","commit_stats":null,"previous_names":["kazedevid/wwebpy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fwwebpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fwwebpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fwwebpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fwwebpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KazeDevID","download_url":"https://codeload.github.com/KazeDevID/wwebpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418658,"owners_count":20773934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T01:13:39.532Z","updated_at":"2025-03-31T04:37:18.487Z","avatar_url":"https://github.com/KazeDevID.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- header --\u003e\n        \u003ch1 style=\"text-align: left; margin-top:0px;\"\u003e\n          wwebpy, a Python Library for WhatsApp Web Automation\n        \u003c/h1\u003e\n        \n        \u003e Browser automation for WhatsApp Web service with Python \u0026 Selenium.\n        \n        \n        \u003c!-- build --\u003e\n        \u003c!-- [![Build Status][travis-image]][travis-link] --\u003e\n        \n        \n        Project consists to allow a user, with whatsapp installed in their phone,\n        to connect their phone with whatsapp web service https://web.whatsapp.com and \n        to automate the functionalities a user normally performs when using whatsapp as a chat app.\n        \n        Some functionalities:\n        1. Reading messages\n        1. Sending messages\n        2. Detecting new messages' notifications.\n        3. Replying to a specific (making a reference to the message you are replying to) message\n        \n        \n        \u003cbr\u003e\u003cbr\u003e\n        \n        ---\n        ## Index:\n        - #### Objectives\n            - Main Goal \u0026 User Story\n                - A) detecting new messages\n                - B) reading new message(s)\n                - C) replying a message\n                - D) send a message\n        - #### Code Examples\n            - Login into whatsapp web, check you are logged in \u0026 logout\n            - Get all opened chats, go into the chat, read the last 10 messages from your friend and reply to the most recent message\n            - More examples\n        - #### Information\n        - #### Maintainer\n        \n        \u003cbr\u003e\u003cbr\u003e\n        \n        ---\n        ## Objectives\n        ### Main Goal \u0026 User Story\n        wwebpy can detect new message(s), read them, analyse it and reply if needed.\n        \n        #### A) detecting new messages\n         1. get wwebpy_opened_chats\n         2. inspect available user from top-bottom for notifications (only on available browser screen view)\n         3. click on the opened chat found with a new message notification icon\n        \n        #### B) reading new message(s)\n         1. get contact_chat\n         2. find \"n unread messages\" section\n         3. get first unread msg\n         4. read and analyse msg\n        \n        #### C) replying a message\n         1. get(hover) the reply icon (on the right-side of the message)\n         2. click on the reply icon\n         3. get the reply link(\"Reply\")\n         4. click the reply link (on browser: it puts cursor on the contact_send_message[message_field])\n        \n        #### D) send a message\n         1. get contact_send_message\n         2. write message\n         3. press enter to send msg.\n        \n        \n        ## Code Examples\n        For the library we are using the Page Pattern recommended by the selenium\n        python library.\n        \n        ### Login into whatsapp web, check you are logged in \u0026 logout\n        ```python\n        import time\n        \n        from selenium import webdriver\n        \n        from wwebpy.accounts.pages import LoginPage\n        from wwebpy.header.pages import HeaderPage\n        from wwebpy.pages import BasePage\n        \n        # Creating the driver (browser)\n        driver = webdriver.Firefox()\n        driver.maximize_window()\n        \n        # 1. Login\n        #       and uncheck the remember check box\n        #       (Get your phone ready to read the QR code)\n        login_page = LoginPage(driver)\n        login_page.load()\n        login_page.remember_me = False\n        time.sleep(7)\n        \n        \n        # 2. The base page is inherited by all pages\n        #       and here you can check whether any\n        #       page is available on the screen of\n        #       the browser.\n        \n        # we don't need to load the pages as whatsapp\n        # web works as one-page web app\n        base_page = BasePage(driver)\n        base_page.is_title_matches()\n        base_page.is_welcome_page_available()\n        base_page.is_nav_bar_page_available()\n        base_page.is_search_page_available()\n        base_page.is_pane_page_available()\n        # chat is only available after you open one\n        base_page.is_chat_page_available()\n        \n        \n        # 3. Logout\n        header_page = HeaderPage(driver)\n        header_page.logout()\n        \n        # Close the browser\n        driver.quit()\n        ```\n        \n        ### Get all opened chats, go into the chat, read the last 10 messages from your friend and reply to the most recent message\n        ```python\n        import time\n        \n        from selenium import webdriver\n        \n        from wwebpy.accounts.pages import LoginPage\n        from wwebpy.chat.pages import ChatPage\n        from wwebpy.chats.pages import PanePage\n        from wwebpy.header.pages import HeaderPage\n        \n        \n        # Creating the driver (browser)\n        driver = webdriver.Firefox()\n        driver.maximize_window()\n        \n        # Login\n        #       and uncheck the remember check box\n        #       (Get your phone ready to read the QR code)\n        login_page = LoginPage(driver)\n        login_page.load()\n        time.sleep(7)\n        \n        \n        # 1. Get all opened chats\n        #       opened chats are the one chats or conversations\n        #       you already have in your whatsapp.\n        #       IT WONT work if you are looking for a contact\n        #       you have never started a conversation.\n        pane_page = PanePage(driver)\n        \n        # get all chats\n        opened_chats = pane_page.opened_chats\n        \n        # iterating over them\n        for oc in opened_chats:\n            print(oc.name)  # contact name (as appears on your whatsapp)\n            print(oc.icon)  # the url of the image\n            print(oc.last_message)\n            print(oc.last_message_time)  # datetime object\n            print(oc.has_notifications())  # are there unread messages?\n            print(oc.notifications)  # returns a integer with the qty of new messages, if there are.\n        \n        \n        # 2. Go into the chat\n        #       just click on one to open the chat page\n        #       (where the conversation is happening)\n        first_chat = opened_chats[0]\n        first_chat.click()\n        \n        # 3. Read the last 10 messages from your contact\n        chat_page = ChatPage(driver)\n        msgs = chat_page.messages.newest(10, filterby='contact')\n        \n        for msg in msgs:\n            print(msg.contact) # name (all should be the same)\n            print(msg.date)\n            print(msg.text)\n            print(msg.status)\n        \n        \n        # 4. Reply to the most recent message\n        msg = msgs[0]  # get the first of the messages query done in previous step\n        msg = chat_page.messages.newest(filterby='contact')\n        # Be careful as library can only now reply to text message\n        # Replying to a msg type (video, image, giff, etc) is not implemented yet. \n        msg.reply(\"This a reply to a specific text msg.\")\n        \n        \n        # Logout\n        header_page = HeaderPage(driver)\n        header_page.logout()\n        \n        # Close the browser\n        driver.quit()\n        ```\n        \n        ### More examples\n        For more functionalities that is offered by the library please check\n        the [tests](https://github.com/KazeDevID/wwebpy/tree/master/wwebpy/tests). Here a couple:\n        - [Send a multi line message](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L341)\n        - [Send an animated message](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L353)\n        - [Get (If there are any) unread messages](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L85)\n        - [Get the oldest message](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L124)\n        - [Get all messages (order by default: newest)](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L157)\n        - [Get most only your recents messages](https://github.com/KazeDevID/wwebpy/blob/75889e0517d2fa0913b52131814d416d908976da/wwebpy/tests/chat.py#L190)\n        \n        _**Note:** If you will try to run the test yourself locally, some of them won't\n        work as some tests are done offline with some html templates that are not available\n        in the repo_\n        \n        \u003c!--\n        ## Whatsapp Web UI\n        - left side (top-bottom)\n          - header (profile, status, new chat, menu)\n          - search (chats, groups, contacts[new chat], messages)\n          - opened_chats (chat, contact icon, contact name, arrow status, truncated msg, time, new msg notification(opt))\n        \n            NOTE: chats are visible only when scrolling and are visible on the screen of the browser.\n            \n        - right side (top-bottom)\n          - contact_detail (contact icon, contact name, ... , search, attachment, menu)\n          - contact_chat (messages)\n          - contact_send_message (smileys, message_field, record audio)\n        \n        \n        ------------------------------------------------\n        ------------------------------------------------\n        #### In Current Chat\n        - wwebpy can send a message\n        - wwebpy can receive a message\n        #### ~In Current Chat\n        - wwebpy can search people in open chats...\n        --\u003e\n        \n        \u003cbr\u003e\n        \n        ## Information:\n        | Technology Stack |  |  |\n        | :- | :-: | :- |\n        | Python                    | ![language][python]                   | Language |\n        | Selenium                  | ![selenium][selenium]                 | Browser Automation |\n        | Whatsapp Web              | ![whatsapp][whatsapp]                 | Chat Service |\n        \n        \u003cbr\u003e\u003cbr\u003e\n        \n        \n        ## Maintainer\n        Get in touch -–\u003e [KazeDevID][KazeDevID]\n        \n        \n        \u003c!-- Links --\u003e\n        \u003c!-- Profiles --\u003e\n        [github-profile]: https://github.com/KazeDevID/\n        [youtube channel]: https://youtube.com/@KazeDevID\n        [Instagram]: https://Instagram.com/lordagam23_/\n        \u003c!-- Extra --\u003e\n        \n        \u003c!-- Repos --\u003e\n        [github-repo]: https://github.com/KazeDevID/wwebpy\n        \n        \u003c!-- Builds --\u003e\n        [travis-link]: https://travis-ci.org/\n        [travis-image]: https://travis-ci.org/\n        \n        \u003c!-- images --\u003e\n        [python]: readme/python.png\n        [selenium]: readme/selenium.png\n        [whatsapp]: readme/whatsapp.png\nPlatform: UNKNOWN\nClassifier: Programming Language :: Python :: 3.8\nClassifier: License :: OSI Approved :: MIT License\nClassifier: Operating System :: OS Independent\nClassifier: Development Status :: 4 - Beta\nClassifier: Environment :: Web Environment :: Mozilla\nClassifier: Natural Language :: English\nClassifier: Topic :: Communications :: Chat\nRequires-Python: \u003e=3.6\nDescription-Content-Type: text/markdown\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazedevid%2Fwwebpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkazedevid%2Fwwebpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazedevid%2Fwwebpy/lists"}