简体   繁体   中英

Python Splinter issue

I just installed Splinter, input simple code like below but have error. Can someone help me on this? Thanks.

from splinter import Browser

b=Browser()
url = "http://www.google.com"

b.visit(url)

Error messages:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/ init .py", line 184, in visit self.driver.get(url) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 245, in get self.execute(Command.GET, {'url': url}) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Target URL www.google.ca is not well-formed. Stacktrace: at FirefoxDriver.prototype.get (file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/driver-component.js:10636) at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command-processor.js:12661) at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command-processor.js:12666) at DelayedCommand.prototype.execute/< (file:///tmp/tmpsIlz0H/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)

Try this instead:

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

Docs here: https://splinter.readthedocs.org/en/latest/#sample-code

The method above handles quitting the browser. Your method, also in the docs, should work (it works for me). Try it again, I've noticed I get almost the same error as yours, if my url is "www.google.com". Make sure you have "http://" part.

selenium.common.exceptions.WebDriverException: Message: Target URL www.google.com is not well-formed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM