1
我想爲Python使用硒,並且即使是基本程序也只是爲了熟悉硒而遇到問題。目前,我只是試圖打開一個網頁,甚至無法讓它工作。我知道有更簡單的方法來使用python啓動網頁,但我的目標是稍後使用網頁內容,所以這就是我使用硒的原因。嘗試在Python中使用Selenium啓動網頁
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.stackoverflow.com")
這導致了這個錯誤信息,然後啓動一個空白Firefox窗口...
Traceback (most recent call last):
File "C:\Python33\Learning Python\soundcloud_play.py", line 10, in <module>
browser.get("http://www.stackoverflow.com")
File "C:\Python33\lib\site-packages\selenium-2.38.4-py3.3.egg\selenium\webdriver\remote\webdriver.py", line 176, in get
self.execute(Command.GET, {'url': url})
File "C:\Python33\lib\site-packages\selenium-2.38.4-py3.3.egg\selenium\webdriver\remote\webdriver.py", line 162, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python33\lib\site-packages\selenium-2.38.4-py3.3.egg\selenium\webdriver\remote\remote_connection.py", line 349, in execute
return self._request(url, method=command_info[0], data=data)
File "C:\Python33\lib\site-packages\selenium-2.38.4-py3.3.egg\selenium\webdriver\remote\remote_connection.py", line 377, in _request
resp = self._conn.getresponse()
File "C:\Python33\lib\http\client.py", line 1143, in getresponse
response.begin()
File "C:\Python33\lib\http\client.py", line 354, in begin
version, status, reason = self._read_status()
File "C:\Python33\lib\http\client.py", line 324, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: ''
我不明白這是什麼問題或如何去修復它。我正在 Windows 7中, 的Python 3.3.2, 硒2.38.4, 火狐17.0.10
任何想法,將不勝感激。謝謝。
謝謝!我升級到Firefox 26,並解決了這個問題。我甚至沒有意識到我正在運行這樣一箇舊版本的Firefox。 – JohnnyW