E
E
Ernest Vardanyan2020-05-15 16:15:02
Python
Ernest Vardanyan, 2020-05-15 16:15:02

How to fix encoding in bot?

After parsing, the bot throws the result into the channel, but in the form: "\u0414\u0436\u043e\u043d\u043d\u0438", "\u041a\u0435\u0439\u0434\u0436", "\u0421\u0430\u0431- \u0417\u0438\u0440\u043e". Tell me how you can fix the encoding to normal, like UTF-8 is considered

import requests
from selenium import webdriver
import telegram
HEADERS = {'user-agent':'Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 80.0.3987.132 YaBrowser / 20.3.2.242 Yowser / 2.5 Safari / 537.36'}

BOT_TOKEN = 'мой токен'

browser = webdriver.Firefox()
browser.maximize_window()

browser.get('некая ссылка на сайт')

nameone1 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[2]/div/div[1]/div[1]/a/span').text
print(nameone1)
nameone1_massif=nameone1.split()
del nameone1_massif[-1]
print(nameone1_massif, )
bot = telegram.Bot(token=BOT_TOKEN)
bot.send_message(chat_id='-1001208426402', text=nameone1_massif)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question