我正在尝试使用selenium进行Python,并且在运行基本程序时遇到麻烦只是为了熟悉selenium。目前,我只是想打开一个网页,甚至无法让它工作。我知道有更简单的方法可以使用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, Firefox 17.0.10
任何想法都将不胜感激。感谢。
答案 0 :(得分:3)