Python Splinter issue



我刚刚安装了Splinter,输入了下面这样的简单代码,但出现了错误。有人能帮我吗?谢谢

from splinter import Browser
b=Browser()
url = "http://www.google.com"
b.visit(url)

错误消息:

Traceback(最后一次调用):文件",第1行,在文件"/usr/local/lib/python2.7/dist packages/ssplit/driver/webdriver/init.py",184号线,正在访问self.driver.get(url)文件"/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/webdriver.py",第245行,在getself.execute(Command.GET,{'url':url})文件"/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/webdriver.py",第233行,执行中self.error_handler.check_response(response)文件"/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/errorhandler.py",第194行,在check_response中提升exception_class(消息、屏幕、堆栈)selenium.com.mon.exceptions.WebDriverException:消息:目标URLwww.google.ca格式不正确。Stacktrace:位于FirefoxDriver.prototype.get(file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/driver-component.js:10636)在DelayedCommand.prototype.executeInternal/h(file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command processor.js:12661)在DelayedCommand.prototype.executeInternal(file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command processor.js:1266)在DelayedCommand.protype.execule/<(file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command processor.js:12608)

试试这个:

from splinter import Browser
with Browser() as b:
    b.visit("http://www.google.com")

此处的文档:https://splinter.readthedocs.org/en/latest/#sample-代码

上面的方法处理退出浏览器。你的方法,也在文档中,应该有效(它对我有效)。再试一次,我注意到如果我的网址是"www.google.com",我会得到和你几乎相同的错误。请确保你有"http://"部分。

selenium.com.mon.exceptions.WebDriverException:消息:目标URLwww.google.com不是正规的

相关内容

  • 没有找到相关文章

最新更新