Python3 + 硒 + PhantomJS UnicodeDecodeError

Python3 + selenium + PhantomJS UnicodeDecodeError


有人遇到过这个问题吗?如何解决?

您的主要错误似乎是:

File "D:\Continuum\Anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 460, in execute return self._request(command_info[0], url, body=data) File "D:\Continuum\Anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 522, in _request resp = opener.open(request, timeout=self._timeout) File "D:\Continuum\Anaconda3\lib\urllib\request.py", line 526, in open response = self._open(req, data)

请尝试以下步骤:

  • 运行 CCleaner 擦除所有OS杂务的工具。
  • 拍一张System Reboot.
  • 启动时PhantomJS()提供phantomjs二进制文件的绝对路径如下:

    driver = webdriver.PhantomJS(executable_path=r'C:\path\to\phantomjs.exe')
    
  • 确保您的脚本中没有不必要的imports。示例:urllib.request

  • 执行你的Test.