我编写了一个程序,它从 excel 获取信息并通过 python 发送消息。
我使用 selenium 和“span”来查找我需要的元素。
现在,WhatsApp 更改了 HTML,不再有跨度。
旧代码在这里:
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#,所以每种语言都可以。
谢谢你,
埃雷尔。
在删除 span 标签后,检查您尝试废弃的数据周围的任何标签,并相应地调整代码。
跨度没有通用的替代品。您能否提供您想要废弃的标记(至少是跨度标签所在的部分)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)