python - 预期的 str、bytes 或 os.PathLike 对象,而不是元组
问题描述
在尝试打开 chrome 窗口然后将其转到 instagram.com 时,我不断收到预期的 str、字节或 os.PathLike 对象,而不是元组。我正在通过创建一个机器人来练习 python,并且很好奇它为什么会给我这个错误,任何帮助都将不胜感激。编译器将错误定位在“self.driver = webdriver.Chrome(ChromeDriverDownloader().download_and_install())”的代码行上
from selenium import webdriver
from webdriverdownloader import ChromeDriverDownloader
import os
import time
class InstagramBot:
#Does this code when program is ran
def __init__(self, username, password):
#Creates username and password of user
self.username = username
self.password = password
#Opens chrome driver which opens chrome
self.driver = webdriver.Chrome(ChromeDriverDownloader().download_and_install())
self.driver.get('https://www.instagram.com/')
if __name__ == '__main__':
ig_bot = InstagramBot('temp_username', 'temp_password')
解决方案
ChromeDriverDownloader().download_and_install()
返回一个元组。
从文档:
def download_and_install(self, version="latest", os_name=None, bitness=None, show_progress_bar=True):
"""
Method for downloading a web driver binary, extracting it into the download directory and creating a symlink
to the binary in the link directory.
:param version: String representing the version of the web driver binary to download. For example, "2.38".
Default if no version is specified is "latest". The version string should match the version
as specified on the download page of the webdriver binary.
:param os_name: Name of the OS to download the web driver binary for, as a str. If not specified, we will use
platform.system() to get the OS.
:param bitness: Bitness of the web driver binary to download, as a str e.g. "32", "64". If not specified, we
will try to guess the bitness by using util.get_architecture_bitness().
:param show_progress_bar: Boolean (default=True) indicating if a progress bar should be shown in the console.
:returns: Tuple containing the path + filename to [0] the extracted binary, and [1] the symlink to the
extracted binary.
推荐阅读
- haskell - 由于类型错误,无法实现可折叠实例
- haskell - 哈斯克尔。实现一个将字符串作为输入并扩展其压缩表示的函数
- flutter - 如何在标签更改时刷新 appBar 的操作?
- vue.js - 如何在 vue tel 输入中添加搜索国家代码?
- c++ - 我可以从具有不同数字分隔符的 istream 中读取双精度值吗?
- flutter - 颤动悬停式触摸处理 - 无需抬起手指即可检测来自不同小部件的触摸
- javascript - formArray 的 Angular 异步自定义验证器
- c++ - 尝试验证数据时内部有些奇怪
- ajax - 如何将 Json 分配给 drafjs 中的编辑器?
- xamarin.forms - Xamarin:电话号码验证