Answer the question
In order to leave comments, you need to log in
How to change the encoding of received data by selenium WebDriver?
I've been betting for a week now, I can't solve this problem: With the help of Selenium Web Driver, I get data from the site, but there are Russian characters there, and when parsing, it gives an error
UnicodeEncodeError: 'charmap' codec can't encode character
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import ...
os.system('chcp 65001')
...
for i in self.driver.find_elements(By.XPATH, '//*[@id="modal-content"]'):
print(i.get_attribute('innerHTML'))
...
Answer the question
In order to leave comments, you need to log in
Here is the solution to my problem.
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question