# my scraper script file
#-*- coding: utf-8 -*-
from selenium import webdriver
import csv
browser = webdriver.Firefox()
browser.get("http://web.com")
f = open("result.csv", 'w')
writer = csv.writer(f)
then the first method
element = browser.find_element_by_xpath("xpath_addr")
temp = [element.get_attribute("innerHTML").encode("utf-8")]
print temp # ['\xec\x84\something\xa8']
writer.writerow(temp)
this results in the right csv file with my language.(e.g. 한글)
but the second case, which I think just a little different
element = browser.find_element_by_xpath("xpath_addr")
temp = element.get_attribute("innerHTML").encode("utf-8")
print temp # "한글"
writer.writerow(temp)
then the csv file is full of non-character things. What makes this difference? print also gets different results but why? (It must be the problem because of my little knowledge about encoding)