我尝试搜索解决方案,但没有成功,所以这是我最后的希望。其他stackoverflow案件都不适合我。
我试着运行
from selenium import webdriver
b=webdriver.Chrome()
b.get("www.google.com")
但是它只打开一个CCD_ 1页面而没有任何内容。
终端中有
DevTools listening on ws://127.0.0.1:50361/devtools/browser/fef860a9-fd7b-4e53-9367-b7e59b57fa66
Traceback (most recent call last):
File "c:/Microsoft VS Code/CODES/bot.py", line 4, in <module>
b.get("www.google.com")
File "C:UsersistiakAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:UsersistiakAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:UsersistiakAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
(Session info: chrome=85.0.4183.121)
这个。解决这个问题的最佳方法是什么?非常感谢。
.get()
参数必须是一个有效的格式化url,并且在时查看文档会得到InvalidArgumentException
传递给命令的参数无效或格式错误。
尝试将http://
或https://
添加到webdriver.get()
中,因为Selenium认为以www...
开头的URL无效:
b.get("https://www.google.com")