gpt4 book ai didi

python - 如何将长 WhatsApp 消息作为单条消息而不是多条消息发送

转载 作者:太空宇宙 更新时间:2023-11-03 19:55:45 24 4
gpt4 key购买 nike

我在使用 selenium Python 向 WhatsApp Web 发送长消息时遇到问题。我的消息采用 UTF-8 格式。以下是消息示例。

સમરાદિત્યચરિત્ર ભવ – ૧ ભાગ – ૨૫

પ્રથમભવ:-ગુણસેન(રાજા) – અગ્નિશર્મા(પુરોહિતપુત્ર)

રાજમાર્ગપરથીમહાજનોના૧૦૮રથોનેરથમહેલતરફ જતા જોઇને、નગરવાસી લોકો અનેક તર્ક-વિતર્ક કરવા લ ાગ્યા。

另请找到我迄今为止尝试过的代码。

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import codecs
import time

#This code is to deal with the input files
grp_list_file = codecs.open('grp_list.txt','r','utf8')
grp_list_data = grp_list_file.read()
grp_list_split = grp_list_data.split('\n')
grp_list_len = len(grp_list_split)
grp_list_val_data = []

for i in range(grp_list_len):
temp = grp_list_split[i]
temp1 = temp.replace('\ufeff','')
temp2 = temp1.replace('\r','')
grp_list_val_data.append(temp2)
print('Input file processed successfully')


#This block deals with the input message file
msg_list_file = codecs.open('message.txt','r','utf-8')
msg_list_data = msg_list_file.read()
print('Message file input processed successfully')

#Keep this at here to avoid any future issues
grp_list_file.close()
msg_list_file.close()


#Open the whatsapp web
driver = webdriver.Firefox()
driver.get('https://web.whatsapp.com/')
input('Enter anyhing once the QR code has been scanned successfully')
act = ActionChains(driver)


#Let proceed with the sending message to all groups
for i in range(grp_list_len):
name = grp_list_val_data[i]
message = msg_list_data
#Select the group
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()
msg_box = driver.find_element_by_class_name('_3u328')
# msg_box.send_keys(Keys.SHIFT)
act.send_keys(Keys.SHIFT,message).perform()
# msg_box.send_keys(message)
# act.key_up(Keys.SHIFT)
send = driver.find_element_by_class_name('_3M-N-')
time.sleep(10)
send.click()
print('Message sent successfully to : ',name)

任何人都可以帮忙以单条消息而不是多条消息的形式发送整个文本吗?

最佳答案

我在复制粘贴想法的帮助下找到了解决问题的方法。首先,我将数据复制到剪贴板,然后将其粘贴到所需的文本框位置。

非常感谢您的时间和帮助。 :)

关于python - 如何将长 WhatsApp 消息作为单条消息而不是多条消息发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59549995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com