向whatsapp上的人发送音频的Python脚本

2024-06-16 14:08:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了一个python脚本,通过重复地向目标用户发送文本消息来激怒whatsapp上的用户,而且它运行得非常完美。在

# Launch the code and it will open chrome with whatsapp automatically. Scan the QR Code with your mobile
# whatsapp so that your contacts load into webpage. You have to download Chromedriver first. You also  have to
# install selenium library. I did it by writing "pip install selenium" in command prompt. You have to make sure
# you have pip pre installed. Otherwise you have to install pip first and then selenium library.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
# Place the link of downloaded and extracted  chromedriver.exe location in inverted commas. For my case it is
# like below:
driver=webdriver.Chrome("C:\setups\chromedriver\chromedriver.exe")

driver.get("https://web.whatsapp.com/")

name=input("Enter the name of person or group: ")
count=eval(input("How many times: "))

input("Wait for ENTER")

user=driver.find_element_by_xpath('//span[@title="{}"]'.format(name))
user.click()
msg_box=driver.find_element_by_class_name("_1Plpp")
for msg in range(count):
    msg_box.send_keys("Sending you message with a minute delay this time")
    button=WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.CLASS_NAME, '_35EW6')))
    button.click()
    time.sleep(60)

我需要帮助,如果我想用谷歌云生成的语音发送同样的信息呢。我曾经使用过googlecloud文本到语音转换,因此生成语音消息都不是问题。假设googlecloud保存了桌面上生成的音频。现在如何发送给目标对象?在

  1. Whatsapp attach icon image当我单击它时,它会扩展为4个图标。我也不确定它的等级。

  2. 我无法检查第一个紫色图标,并找到它的类或任何东西,以便我可以选择它。

  3. 即使我这么做了,它也会打开这个盒子。Open Pop up Box。如何设置到桌面的路径并选择文件?


Tags: andthetonamefromimportyouby