{"id":347959,"date":"2023-05-27T15:01:27","date_gmt":"2023-05-27T15:01:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347959"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347959","title":{"rendered":"<span>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 WhatsApp (\u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0432\u0441\u0435\u043c!<\/p>\n<p>\u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u0435\u043d\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/articles\/735394\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/a>.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Whatsapp \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ul>\n<li>\n<p>Python  (\u0443 \u043c\u0435\u043d\u044f 3.10.10)<\/p>\n<\/li>\n<li>\n<p>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a \u043d\u0435\u043c\u0443 (\u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0445 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 Whatsapp<\/p>\n<\/li>\n<li>\n<p>Windows \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>&#8230; \u043d\u0443 \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 <\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0439 requrements.txt<\/p>\n<pre><code>async-generator==1.10 attrs==23.1.0 certifi==2023.5.7 cffi==1.15.1 charset-normalizer==3.1.0 colorama==0.4.6 exceptiongroup==1.1.1 h11==0.14.0 idna==3.4 outcome==1.2.0 packaging==23.1 PyAutoIt==0.6.5 pycparser==2.21 PySocks==1.7.1 python-dotenv==1.0.0 requests==2.30.0 selenium==4.9.1 sniffio==1.3.0 sortedcontainers==2.4.0 tqdm==4.65.0 trio==0.22.0 trio-websocket==0.10.2 urllib3==2.0.2 webdriver-manager==3.8.6 wsproto==1.2.0<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, <strong>\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c PyAutoIt<\/strong>,  \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437  <\/p>\n<pre><code>pip install -r requrements.txt <\/code><\/pre>\n<p>\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 PyAutoit \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Selenium, \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438,  \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u043b\u0430\u0442\u044c  \u0442\u0435\u043a\u0441\u0442 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u0410 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c Windows Explorer \u0447\u0442\u043e \u0437\u0430 \u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043b\u0435\u0436\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435. \u041a \u0441\u043b\u043e\u0432\u0443, AutoIt &#8212; \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 API. \u041e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c, \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0438 \u0432 windows \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<ol>\n<li>\n<p> \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 <a href=\"https:\/\/github.com\/jacexh\/pyautoit\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a><\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0432, \u0435\u0441\u043b\u0438 \u0442\u0430\u0449\u0438\u043b\u0438 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 git clone<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 pyautoit-master<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c python <a href=\"http:\/\/setup.py\" rel=\"noopener noreferrer nofollow\">setup.py<\/a> install&#8230; \u0432\u043f\u0440\u043e\u0447\u0435\u043c \u0432 <a href=\"http:\/\/README.md\" rel=\"noopener noreferrer nofollow\">README.md<\/a> \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 ;).<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0443 \u0432\u043e\u0442, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0430\u0439\u043b  <a href=\"http:\/\/whatsapp.py\" rel=\"noopener noreferrer nofollow\">whatsapp.py<\/a>. \u0412\u043e\u0442 \u043e\u043d <\/p>\n<pre><code>from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.support.ui import WebDriverWait from time import sleep import argparse import autoit  options = webdriver.ChromeOptions() # \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 FireFox, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u043c options = webdriver.FirefoxOptions() . # if you have the Mozilla Fifefox just write                   options = webdriver.FirefoxOptions() options.add_argument('--allow-profiles-outside-user-dir') options.add_argument('--enable-profile-shortcut-manager') # \u0423\u041a\u0410\u0416\u0418\u0422\u0415 \u041f\u0423\u0422\u042c \u0413\u0414\u0415 \u041b\u0415\u0416\u0418\u0422 \u0412\u0410\u0428 python \u0424\u0410\u0419\u041b. \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u0435\u0433\u043e # Specify the path to where your python file is located. I suggest you create a separate folder for it options.add_argument(r'user-data-dir=x:\\\\yyyyyy\\\\zzzzzz\\\\')  options.add_argument('--profile-directory=Profile 1') options.add_argument('--profiling-flush=n') options.add_argument('--enable-aggressive-domstorage-flushing')  # \u044d\u0442\u0438 \u043e\u043f\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0430\u0432\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445  SSL, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0442.\u043f. \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f :( # these options need to disabled any messages about bad ssl, certification &amp; etc  options.add_argument('--ignore-certificate-errors-spki-list') options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors') options.add_argument('log-level=3') # INFO = 0,  # WARNING = 1,  # LOG_ERROR = 2,  # LOG_FATAL = 3. # default is 0.  # \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f Selenium # Constants for Selenium xpath = \"\/\/button[@data-testid='compose-btn-send']\" xpathAttach = \"\/\/div[@data-testid='conversation-clip']\" # xpathFile = \"\/\/button[@data-testid='attach-document']\" #xpathSendButton = \"\/\/div[@data-testid='send']\" # data-testid = \"send\" cssIdOfDocument = \"[aria-label='\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442']\" cssIdOfSendButton = \"[aria-label='\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c']\"  # \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f AutoIt # Constant for Autoit idExplorerOpen = \"[CLASS:#32770]\" idInputLine = \"[CLASS:Edit; INSTANCE:1]\" idOpenButton = \"Button1\"  # \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 # numbers of  phones to send numbers = [\"+7xxxxxxxxxx\", \"+7xxxxxxxxxx\", \"+7xxxxxxxxxx\"]  # \u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e # default text text = \"\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442\"  # \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 # We are starting a browser driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) # \u0436\u0434\u0451\u043c \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 # it takes some time to load it wait = WebDriverWait(driver, 30)   def main(args):     for number in numbers: # \u0441\u043e\u0437\u0434\u0430\u0451\u043c url \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 # create a url page with a phone number and text to send         url = f\"https:\/\/web.whatsapp.com\/send?phone={number}&amp;text={args.text}\" # \u0438\u0434\u0451\u043c \u0442\u0443\u0434\u0430 # go to there         driver.get(url) # \u0436\u0434\u0451\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b Whatsapp # we are waiting for Whatsapp page to load         wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))          if not (args.file is None) : # \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b # \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 Attach # need to send file # now we look for the Attach Button and click on it            driver.find_element(By.XPATH, xpathAttach).click() # \u0437\u0430\u0442\u0435\u043c \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\" \u0438 \u0449\u0435\u043b\u043a\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 CCS, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 ID # then  we look for the Document Button and click on it. Used CCS attribute because it doesn't have any ID            driver.find_element(By.CSS_SELECTOR, cssIdOfDocument).click()  # \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 Windows # wait when the Windows's explorer window to activate            autoit.win_wait_active(idExplorerOpen, 5) # \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0432\u043e\u0434\u0430 # then we are sending the path of the file to input line            autoit.control_send(idExplorerOpen, idInputLine, args.file) # \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043a\u0440\u044b\u0442\u044c\"  # and are clicking the Open Button             autoit.control_click(idExplorerOpen, idOpenButton) # \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0436\u0434\u0451\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 # it takes some time to load a file            sleep(5) # \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\" \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 CCS, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 ID # we look for the Send Button and click on it. Used CCS attribute because it doesn't have any ID            driver.find_element(By.CSS_SELECTOR, cssIdOfSendButton).click()                     else: # \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\" \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0435 # now we look for the Send Button and click on it            driver.find_element(By.XPATH, xpath).click() # \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f # it takes some time to send a file or a message         sleep(5) # \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 # close all     driver.quit()   if __name__ == '__main__': # \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 # we are parsing command line parameters      parser = argparse.ArgumentParser(description='Send information by Whatsapp')      parser.add_argument('--text', help='Text for send', required=False, default = text)      parser.add_argument('--file', help='File for send', required=False)      args = parser.parse_args() # \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 # start sending      main(args)     <\/code><\/pre>\n<p> \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u0447\u0451\u043c \u043d\u0430 \u0434\u0432\u0443\u0445 \u044f\u0437\u044b\u043a\u0430\u0445: \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0438 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u0440\u0443\u0441\u0441\u043a\u0438\u043c ;). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u0438, \u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a <\/p>\n<pre><code>python whatsapp.py --text \"\u042f \u043f\u043e\u0441\u044b\u043b\u0430\u044e \u0442\u0435\u0431\u0435 ... \u0438\u043b\u0438 \u0442\u0435\u0431\u044f ;)\" <\/code><\/pre>\n<p> \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442<\/p>\n<p>\u0438\u043b\u0438 \u0442\u0430\u043a <\/p>\n<pre><code>python --text \"\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\" --file \"x:\\yyyyy\\zzzzz\\fileToSend.ext\"<\/code><\/pre>\n<p>\u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432, \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u0442\u0438\u043c. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c whatsapp \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0438 \u043e\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0451 \u0431\u0435\u0437 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0448\u0443\u0441\u044c \u0441 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043d\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b \u0438 \u043f\u0440\u043e\u0446\u0438\u0442\u0438\u0440\u0443\u044e \u0435\u0433\u043e: <\/p>\n<blockquote>\n<p>\u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0441 \u0446\u0435\u043b\u044c\u044e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0432\u0430\u0441 \u0441\u043f\u0430\u043c\u0438\u0442\u044c, \u0444\u043b\u0443\u0434\u0438\u0442\u044c \u0438 \u043f\u043e\u0440\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043b\u044e\u0434\u044f\u043c \u0438\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u042d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0435\u0441\u0451\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u0414\u0443\u043c\u0430\u0439\u0442\u0435, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.  <\/p>\n<\/blockquote>\n<p> \u0412\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u0438!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/737990\/\"> https:\/\/habr.com\/ru\/articles\/737990\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0432\u0441\u0435\u043c!<\/p>\n<p>\u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u0435\u043d\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/articles\/735394\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f<\/a>.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Whatsapp \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ul>\n<li>\n<p>Python  (\u0443 \u043c\u0435\u043d\u044f 3.10.10)<\/p>\n<\/li>\n<li>\n<p>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a \u043d\u0435\u043c\u0443 (\u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0445 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0432 Whatsapp<\/p>\n<\/li>\n<li>\n<p>Windows \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>&#8230; \u043d\u0443 \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 <\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0439 requrements.txt<\/p>\n<pre><code>async-generator==1.10 attrs==23.1.0 certifi==2023.5.7 cffi==1.15.1 charset-normalizer==3.1.0 colorama==0.4.6 exceptiongroup==1.1.1 h11==0.14.0 idna==3.4 outcome==1.2.0 packaging==23.1 PyAutoIt==0.6.5 pycparser==2.21 PySocks==1.7.1 python-dotenv==1.0.0 requests==2.30.0 selenium==4.9.1 sniffio==1.3.0 sortedcontainers==2.4.0 tqdm==4.65.0 trio==0.22.0 trio-websocket==0.10.2 urllib3==2.0.2 webdriver-manager==3.8.6 wsproto==1.2.0<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, <strong>\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c PyAutoIt<\/strong>,  \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437  <\/p>\n<pre><code>pip install -r requrements.txt <\/code><\/pre>\n<p>\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 PyAutoit \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Selenium, \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438,  \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u043b\u0430\u0442\u044c  \u0442\u0435\u043a\u0441\u0442 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u0410 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c Windows Explorer \u0447\u0442\u043e \u0437\u0430 \u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043b\u0435\u0436\u0438\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435. \u041a \u0441\u043b\u043e\u0432\u0443, AutoIt &#8212; \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 API. \u041e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c, \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0438 \u0432 windows \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<ol>\n<li>\n<p> \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 <a href=\"https:\/\/github.com\/jacexh\/pyautoit\" rel=\"noopener noreferrer nofollow\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a><\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0432, \u0435\u0441\u043b\u0438 \u0442\u0430\u0449\u0438\u043b\u0438 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 git clone<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 pyautoit-master<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c python <a href=\"http:\/\/setup.py\" rel=\"noopener noreferrer nofollow\">setup.py<\/a> install&#8230; \u0432\u043f\u0440\u043e\u0447\u0435\u043c \u0432 <a href=\"http:\/\/README.md\" rel=\"noopener noreferrer nofollow\">README.md<\/a> \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 ;).<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0443 \u0432\u043e\u0442, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0430\u0439\u043b  <a href=\"http:\/\/whatsapp.py\" rel=\"noopener noreferrer nofollow\">whatsapp.py<\/a>. \u0412\u043e\u0442 \u043e\u043d <\/p>\n<pre><code>from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.support.ui import WebDriverWait from time import sleep import argparse import autoit  options = webdriver.ChromeOptions() # \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 FireFox, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u043c options = webdriver.FirefoxOptions() . # if you have the Mozilla Fifefox just write                   options = webdriver.FirefoxOptions() options.add_argument('--allow-profiles-outside-user-dir') options.add_argument('--enable-profile-shortcut-manager') # \u0423\u041a\u0410\u0416\u0418\u0422\u0415 \u041f\u0423\u0422\u042c \u0413\u0414\u0415 \u041b\u0415\u0416\u0418\u0422 \u0412\u0410\u0428 python \u0424\u0410\u0419\u041b. \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u0435\u0433\u043e # Specify the path to where your python file is located. I suggest you create a separate folder for it options.add_argument(r'user-data-dir=x:\\\\yyyyyy\\\\zzzzzz\\\\')  options.add_argument('--profile-directory=Profile 1') options.add_argument('--profiling-flush=n') options.add_argument('--enable-aggressive-domstorage-flushing')  # \u044d\u0442\u0438 \u043e\u043f\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0430\u0432\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445  SSL, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0442.\u043f. \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f :( # these options need to disabled any messages about bad ssl, certification &amp; etc  options.add_argument('--ignore-certificate-errors-spki-list') options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors') options.add_argument('log-level=3') # INFO = 0,  # WARNING = 1,  # LOG_ERROR = 2,  # LOG_FATAL = 3. # default is 0.  # \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f Selenium # Constants for Selenium xpath = \"\/\/button[@data-testid='compose-btn-send']\" xpathAttach = \"\/\/div[@data-testid='conversation-clip']\" # xpathFile = \"\/\/button[@data-testid='attach-document']\" #xpathSendButton = \"\/\/div[@data-testid='send']\" # data-testid = \"send\" cssIdOfDocument = \"[aria-label='\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442']\" cssIdOfSendButton = \"[aria-label='\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c']\"  # \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f AutoIt # Constant for Autoit idExplorerOpen = \"[CLASS:#32770]\" idInputLine = \"[CLASS:Edit; INSTANCE:1]\" idOpenButton = \"Button1\"  # \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 # numbers of  phones to send numbers = [\"+7xxxxxxxxxx\", \"+7xxxxxxxxxx\", \"+7xxxxxxxxxx\"]  # \u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e # default text text = \"\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442\"  # \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 # We are starting a browser driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) # \u0436\u0434\u0451\u043c \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 # it takes some time to load it wait = WebDriverWait(driver, 30)   def main(args):     for number in numbers: # \u0441\u043e\u0437\u0434\u0430\u0451\u043c url \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0438 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 # create a url page with a phone number and text to send         url = f\"https:\/\/web.whatsapp.com\/send?phone={number}&amp;text={args.text}\" # \u0438\u0434\u0451\u043c \u0442\u0443\u0434\u0430 # go to there         driver.get(url) # \u0436\u0434\u0451\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b Whatsapp # we are waiting for Whatsapp page to load         wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))          if not (args.file is None) : # \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b # \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 Attach # need to send file # now we look for the Attach Button and click on it            driver.find_element(By.XPATH, xpathAttach).click() # \u0437\u0430\u0442\u0435\u043c \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\" \u0438 \u0449\u0435\u043b\u043a\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 CCS, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 ID # then  we look for the Document Button and click on it. Used CCS attribute because it doesn't have any ID            driver.find_element(By.CSS_SELECTOR, cssIdOfDocument).click()  # \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 Windows # wait when the Windows's explorer window to activate            autoit.win_wait_active(idExplorerOpen, 5) # \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0432\u043e\u0434\u0430 # then we are sending the path of the file to input line            autoit.control_send(idExplorerOpen, idInputLine, args.file) # \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043a\u0440\u044b\u0442\u044c\"  # and are clicking the Open Button             autoit.control_click(idExplorerOpen, idOpenButton) # \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0436\u0434\u0451\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 # it takes some time to load a file            sleep(5) # \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\" \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442 CCS, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 ID # we look for the Send Button and click on it. Used CCS attribute because it doesn't have any ID            driver.find_element(By.CSS_SELECTOR, cssIdOfSendButton).click()                     else: # \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0449\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \"\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\" \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0435 # now we look for the Send Button and click on it            driver.find_element(By.XPATH, xpath).click() # \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f # it takes some time to send a file or a message         sleep(5) # \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 # close all     driver.quit()   if __name__ == '__main__': # \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 # we are parsing command line parameters      parser = argparse.ArgumentParser(description='Send information by Whatsapp')      parser.add_argument('--text', help='Text for send', required=False, default = text)      parser.add_argument('--file', help='File for send', required=False)      args = parser.parse_args() # \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 # start sending      main(args)     <\/code><\/pre>\n<p> \u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u0447\u0451\u043c \u043d\u0430 \u0434\u0432\u0443\u0445 \u044f\u0437\u044b\u043a\u0430\u0445: \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0438 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u0440\u0443\u0441\u0441\u043a\u0438\u043c ;). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u0438, \u043d\u043e \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a <\/p>\n<pre><code>python whatsapp.py --text \"\u042f \u043f\u043e\u0441\u044b\u043b\u0430\u044e \u0442\u0435\u0431\u0435 ... \u0438\u043b\u0438 \u0442\u0435\u0431\u044f ;)\" <\/code><\/pre>\n<p> \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442<\/p>\n<p>\u0438\u043b\u0438 \u0442\u0430\u043a <\/p>\n<pre><code>python --text \"\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\" --file \"x:\\yyyyy\\zzzzz\\fileToSend.ext\"<\/code><\/pre>\n<p>\u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432, \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c \u0441 \u044d\u0442\u0438\u043c. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c whatsapp \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0438 \u043e\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0451 \u0431\u0435\u0437 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0448\u0443\u0441\u044c \u0441 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043d\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b \u0438 \u043f\u0440\u043e\u0446\u0438\u0442\u0438\u0440\u0443\u044e \u0435\u0433\u043e: <\/p>\n<blockquote>\n<p>\u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0441 \u0446\u0435\u043b\u044c\u044e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0432\u0430\u0441 \u0441\u043f\u0430\u043c\u0438\u0442\u044c, \u0444\u043b\u0443\u0434\u0438\u0442\u044c \u0438 \u043f\u043e\u0440\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043b\u044e\u0434\u044f\u043c \u0438\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u042d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043d\u0435\u0441\u0451\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u0414\u0443\u043c\u0430\u0439\u0442\u0435, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.  <\/p>\n<\/blockquote>\n<p> \u0412\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u0438!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/737990\/\"> https:\/\/habr.com\/ru\/articles\/737990\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347959","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347959"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347959\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}