Python+Selenium+Phantomjs+Unicodeerror: utf-8 codec cant decode by

2024-03-29 10:55:44 发布

您现在位置:Python中文网/ 问答频道 /正文

几天前,我可以成功地运行代码,但是,今天,当我使用selenium+Phantomjs时,出现了一个Unicoderroe。在

from selenium import webdriver
driver = webdriver.PhantomJS()
#Unicodeerror occur
driver.get(url)

Traceback (most recent call last):
  File "C:\Users\name\Desktop\test.py", line 12, in <module>
    driver = webdriver.PhantomJS()
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 58, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 98, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 185, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 247, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 464, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\name\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 537, in _request
    body = data.decode('utf-8').replace('\x00', '').strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 189: invalid start byte

Python\Python35\lib\site packages\selenium\webdriver\remote\remote中的UnicodeDecodeError occcur_连接.py在

我不知道怎么修,请帮帮我


Tags: nameinpyremotelibpackageslocalselenium