【问题标题】:How to detect a notification in whatsapp to trigger an action in python?如何检测whatsapp中的通知以触发python中的操作?
【发布时间】:2021-04-03 20:21:22
【问题描述】:

我希望每次我在 whatsapp 中收到通知(对于 led 部分,我使用 pyserial)时,都能用 python 打开一个 led,但我不知道哪个工具(库)最适合 检测通知并使用它来触发 LED,我是新手,我尝试过使用 selenium,但我只是不太了解它,我只是想知道 selenium 是否是最好的方法解决这个问题,或者有其他工具可以解决这个问题。

Currently im trying to approach this problem by detecting the change in a whatsapp class called "_2gsiG", (i don't know if it is the same class for everyone, but it is the green bubble it appears in the image), because it tells you how many messages you recive in just one chat, when i realize i have to do this for every contact, so i don't think this is an efficient solution

提前谢谢你。

【问题讨论】:

  • 你有没有考虑过使用WhatsApp API而不是selenium?你可以设置一个 webhook 来触发你的 python LED 程序。
  • @khuynh 谢谢我注意到 whatsapp API 它是一项付费服务​​,但我会这样尝试

标签: python selenium push-notification notifications whatsapp


【解决方案1】:

这可以寻找绿色通知球并点击它

try:
    search = driver.find_elements_by_class_name("_23LrM") # search for the green ball counter notificator in whatsapp web
except:
    search = []

if search != []: # Se detecta notificación
    print("Notification detected!"
    search[0].click()

【讨论】:

    猜你喜欢
    • 2017-08-30
    • 1970-01-01
    • 2016-12-30
    • 2021-09-27
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多