2016-01-08 11 views
7

muszę wysyłać emotikony z selenem, na przykład:python selen send_keys emotikony znaków

i selenu zwraca błąd , Testowałem z .send_keys(unicode(bio_text, 'ascii')) # iso-8859-1, ten sam wynik.

Jak mogę wysłać te postacie z python selenu?

kod Python: przykład

driver.find_element_by_id("biography").clear() 
driver.find_element_by_id("biography").send_keys(unicode('���������✊���������', 'ascii')) # iso-8859-1 

emotikony:

���������✊��������� 
+0

Należy próbować z 'encode ('utf-8')'. Bez [mcve] (http://stackoverflow.com/help/mcve) nie możemy tu wiele pomóc ... – Cyrbil

+0

yess im spróbować i podać ten sam błąd – seoexpert

+0

A jaki jest błąd? – Cyrbil

Odpowiedz

0

Oto co zrobiłem.

# -*- coding: utf-8 -*- 
from selenium import webdriver 

driver = webdriver.Chrome() 
driver.get('https://google.com') 

text = u"''" 
text = text.replace("'", "\\'") # escape single quotes 
text = text.encode('utf-8') # needed to make format function work 

driver.execute_script(
    "document.getElementById('lst-ib').value = '{data}'".format(
     data=text 
    ))