我需要用selenium发送表情符号,例如:
�������✊????�????�????�????�????�����
硒返回一个错误,我测试了.send_keys(unicode(bio_text, 'ascii')) # iso-8859-1
,结果相同。
如何使用 python selenium 发送这些字符?
蟒蛇代码:
driver.find_element_by_id("biography").clear()
driver.find_element_by_id("biography").send_keys(unicode('���������✊????�????�????�????�????�����', 'ascii')) # iso-8859-1
表情符号示例:
���������✊????�????�????�????�????�����
这就是我所做的。
# -*- 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
))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)