首页 > 解决方案 > 需要帮助解决 python 中的 selenium webdriver

问题描述

我正在使用 PyCharm,并且正在关注 YouTube 教程。复制他们的方法后,我没有得到想要的结果。


from selenium import webdriver

class InstaBot:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get("https://instagram.com")

InstaBot()
Traceback (most recent call last):
  File "/Users/prxthm/PycharmProjects/untitled1/bot.py", line 10, in <module>
    InstaBot()
  File "/Users/prxthm/PycharmProjects/untitled1/bot.py", line 7, in __init__
    self.driver = webdriver.Chrome()
AttributeError: 'function' object has no attribute 'Chrome'

标签: python-3.xseleniumwebdriver

解决方案


给出以这种格式保存 chromedriver 的路径,我已经输入了保存 webdriver.exe 文件的路径:

driver = webdriver.Chrome(executable_path="C:\\Users\\dt\\workspace_python\\drivers\\chromedriver.exe")

尝试使用两个\\


推荐阅读