簡體   English   中英

如何將您的長 WhatsApp 消息作為一條消息而不是多條消息發送

[英]how to send your long WhatsApp message as a single message instead of multiple messages

我在使用 selenium Python 向 WhatsApp Web 發送長消息時遇到問題。 我的消息是 UTF-8 格式。 以下是該消息的示例。

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

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

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

還請找到我迄今為止嘗試過的代碼。

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)

任何人都可以幫助在單個消息而不是多個消息中發送整個文本。

我在復制粘貼想法的幫助下找到了解決問題的方法。 首先,我將數據復制到剪貼板,然后將其粘貼到所需的文本框位置。

非常感謝您的時間和幫助。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM