from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver=webdriver.chrome(executable_path="C:\Driver\chromedriver_win32\chromedriver.exe")
driver.get("www.youtube.com")
print (driver.title)
driver.close()
对于上面的代码,我得到了错误
TypeError: 'module' object is not callable
我推荐模块化编程
设置一个返回chrome驱动程序的函数,如下所示:
按如下方式调用此函数:
因此,将来如果驱动程序不工作,您不必在每个脚本上都更改它,您可以在一个地方(函数)更改它
相关问题 更多 >
编程相关推荐