python - 如何在 Python - Selenium 中将韩语作为 find_element_by_link_text() 的参数?

标签 python selenium unicode

我在 Python 3.4 中使用 Selenium。

我尝试在 find_element_by_link_text() 方法中放入韩语单词作为参数,但不起作用。

我的意思是它没有产生任何错误,但它找不到任何韩语文本的超链接。

这里是一些示例代码:

from selenium import webdriver

browser = webdriver.PhantomJS()
browser.get('www.certain-korean-web-page.com')
a = browser.find_element_by_link_text('한국말')
print(a)

即使页面源具有该元素,它也会引发 NoSuchElementException (当然,我检查了一个英文元素并且它有效)。

是unicode问题吗?

谢谢。

最佳答案

在 naver.com 上找不到您的代码中提到的元素。但尝试了另一个元素,它对我来说效果很好。代码如下。

# coding=utf-8
from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://www.naver.com/')
a = browser.find_element_by_link_text('네이버뉴스')
print(a)

关于python - 如何在 Python - Selenium 中将韩语作为 find_element_by_link_text() 的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34701982/

相关文章:

c++ - 什么是 C++ GUI 库支持 Windows 的 32 位字符 Unicode

python - 防止 self 分配的 pylint 保护

python - Django 设置未注册更改

python - Selenium 无法启动 Firefox

java - 无法使用 selenium webdriver 滚动滚动条?

java - org.apache.poi.openxml4j.opc.PackageRelationshipCollection 问题

android - 在 strings.xml 中使用 Unicode 字符

c++ - X11 Unicode KeyEvent 问题

python - 识别连续的数据序列并计算其长度

python - HEAD 请求与 GET 请求