python-3.x - 需要帮助解决 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'
解决方案
给出以这种格式保存 chromedriver 的路径,我已经输入了保存 webdriver.exe 文件的路径:
driver = webdriver.Chrome(executable_path="C:\\Users\\dt\\workspace_python\\drivers\\chromedriver.exe")
尝试使用两个\\
推荐阅读
- kotlin-coroutines - 如何让 withTimeoutOrNull 返回 null 但在块中完成代码
- jenkins - Jenkins ThinBackup 计划备份未运行
- solr - 数字同义词
- c - 如何在C中输入由换行符分隔的两个字符串
- ssl - SSL 证书错误 net::ERR_CERT_AUTHORITY_INVALID
- c# - .NET Cryptography 命名空间中的 CNG 类是否经过 FIPS 认证?
- javascript - 如何使用javascript在下面创建嵌套的json对象数组
- tcp - 如何使用 Tokio 的 TcpStream 发送数据流?
- php - PHP Regex - 用完全关闭替换所有自关闭标签
- r - 在 R 中列出两个主要索引