Попытка вызвать данные .xlsx в сценарии python selenium 'Object of type Series is not JSON serializable'
Этот код считывает файл .xlsx и собирает номер мобильного телефона пользователя для отправки сообщения
def watbot(request):
if request.method == 'POST':
file_name = request.POST.get("filename")
pre = os.path.dirname(os.path.realpath(__file__))
f_name = file_name
path = os.path.join(pre, f_name)
f_name = pandas.read_excel(path)
count = 0
driver = webdriver.Chrome(executable_path='D:/Old Data/Integration Files/new/chromedriver')
for column in f_name['Contact'].tolist():
try:
driver.get('https://web.whatsapp.com/send?phone=' + str(f_name['Contact'][count]) + '&text=' + f_name['Messages'][[0]])
sent = False
# It tries 3 times to send a message in case if there any error occurred
try:
sleep(3)
click_btn = driver.find_element(By.XPATH,
'//*[@id="main"]/footer/div[1]/div/span[2]/div/div[2]/div[2]/button/span')
except Exception as e:
print("Sorry message could not sent to " + str(f_name['Contact'][count]))
else:
sleep(1)
click_btn.click()
sent = True
sleep(2)
print('Message sent to: ' + str(f_name['Contact'][count]))
count = count + 1
except Exception as e:
print('Failed to send message to ' + str(f_name['Contact'][count]) + str(e))
return HttpResponse('messeges')
Не удалось отправить сообщение на 7976583223 Объект типа Series не является JSON сериализуемым
Я не понимаю, что не так с кодом, поскольку я уже пробовал метод json.dump()