selenium webdriver - Python UnicodeEncodeError: 'charmap' codec can't encode character '\u2014' in position 15: character maps to <undefined> -
from selenium import webdriver selenium.webdriver.common.keys import keys import unittest driver = webdriver.firefox() driver.maximize_window() driver.implicitly_wait(30) driver.get('http://habrahabr.ru/') q = driver.find_elements_by_xpath("//h1[@class='title']/a[@class='post_title']") driver.close() w in q: print(w.text)
fails specific characters. adding .encode('utf-8') helps fail makes output this: b'\xd0\xa7\xd1\x82\xd0\xbe \xd0. converting w.text string doesn't either. appreciate explanation , solution! thanks!
Comments
Post a Comment