【发布时间】:2018-08-22 01:46:43
【问题描述】:
我做了一个程序,它从 excel 中获取信息并通过 python 发送消息。 我使用 selenium 和“span”来寻找我需要的元素。
现在,WhatsApp 更改了他们的 HTML,不再有 span。
旧代码在这里:
import time
import xlrd
from selenium import webdriver
chrome_driver_binary = "D:\pycharm\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver_binary)
driver.get('http://web.whatsapp.com')
file_location = "C:\Users\ErelNahum\Desktop\data.xlsx"
book = xlrd.open_workbook(file_location)
print "there is " + str(book.nsheets) + " sheets"
sheet = book.sheet_by_index(0)
cols = sheet.ncols - 1
print "the number of cols is " + str(cols)
raw_input('Enter anything after scanning QR code')
for i in range(cols):
tel = sheet.cell_value((i+1), 0)
tel = tel.replace("\"", "")
print tel
messege = sheet.cell_value((i+1), 1)
messege = (messege +str(b+1))
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(tel))
user.click()
msg_box = driver.find_element_by_class_name('_input-container')
msg_box.send_keys(messege)
driver.find_element_by_class_name('compose-btn-send').click()
time.sleep(0.5)
如果您知道如何更改程序以使其正常运行,请告诉我。 我知道 Python、JS、C#,所以每种语言都很好。
谢谢你, 埃雷尔。
【问题讨论】:
-
SO 不是编码服务
-
"via python/JS",那你为什么要标记c#?此外,没有人会在这里免费为您工作。请阅读How to Ask
-
我没有让你写我的代码。我问你是否有想法替换 HTML 中的“spans”。
-
@Erel Nahum,如果 excel 表中的号码未知且未作为联系人保存在联系人中,whatsapp 用户会发生什么情况...是否也会为此类号码打开聊天窗口...? /跨度>
标签: javascript python whatsapp