Whatsapp 自动机器人无法在 WhatsApp 联系人列表中搜索 [英] Whatsapp Automated Bot not able to search in WhatsApp Contact List

查看:98
本文介绍了Whatsapp 自动机器人无法在 WhatsApp 联系人列表中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个 WhatsApp 机器人,它使用 chromedriver 并打开 whatsapp 网络,并向联系人发送消息.这些是程序的步骤:

I'm trying to implement a WhatsApp bot, which uses the chromedriver and opens whatsapp web, and sends messages to the contacts. These are the steps of the program:

  • 从 Excel 文件中读取联系人
  • 设置时间,当你想和你想发送的消息一起发送消息
  • 搜索该名称并发送消息

以下是我无法解决的问题:

Here are the problems that I'm unable to solve:

  1. 如果最近聊天中没有该姓名,则无法从 WhatsApp 联系人列表中搜索并发送
  2. 我也想知道如何发送图片和视频

由于代码很长,这里是它的链接:https://github.com/harshitsidhwa/WhatsApp-bot-selenium

Since the code is pretty long, here is the link to it: https://github.com/harshitsidhwa/WhatsApp-bot-selenium

推荐答案

Python 向联系人发送消息:

Python sending messages to contacts:

def send_message(target):
global message,wait, browser
try:
    x_arg = '//span[contains(@title,' + target + ')]'
    group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg)))
    group_title.click()
    input_box = browser.find_element_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')
    input_box.send_keys(message + Keys.ENTER)
    time.sleep(1)
except NoSuchElementException:
    return

这里的变量 target 是您要向其发送消息的联系人姓名.变量 message 包含您要发送给该联系人的文本消息.变量 browser 是网络驱动程序变量.

Here the variable target is the contact name whom you want to send a message. Variable message contains the text message you want to send to that contact. Variable browser is web driver variable.

我已经在 WhatsApp 自动化工作,如果有任何帮助,请参考链接:https://github.com/shauryauppal/PyWhatsapp

I have already worked on WhatsApp Automation, in case of any help refer to the link: https://github.com/shauryauppal/PyWhatsapp

您已经说明了两个问题:

You have stated two problems:

  1. 您无法通过联系人列表或存档的联系人列表访问联系人姓名.唯一的方法是最近的聊天联系人.对于其他联系人,您必须访问所有联系人列表选择目标人员然后发送消息.(即将实施).

  1. You cannot access to contact names by contact list or archived contact list. The only way is recent chat contacts. For other contacts, you have to visit all contacts list select the target person then send messages. (Will implement soon).

可以通过 PyAutoIt 实现图像、文件和视频的发送.参考我的 repo,我已经实现了.

Sending of Images, Files and Videos can be Implemented by PyAutoIt. Refer my repo, I have already implemented that.

第一步:AutoIt.exe 安装链接

第二步:

pip install PyAutoIt

pip install PyAutoIt

参考我的代码或此链接以获得指导.

Refer my code or this link for guidance.

这篇关于Whatsapp 自动机器人无法在 WhatsApp 联系人列表中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆