gpt4 book ai didi

python - 如何通过 selenium webdriver python 将文件上传到 youtube?

转载 作者:太空宇宙 更新时间:2023-11-03 11:49:36 25 4
gpt4 key购买 nike

不知道如何上传文件?需要拖放或通过对话框选择

最佳答案

"Looks like you cannot upload files on YouTube using the typical sendkeys method"

4年后...
@chandan-nayak:可以,这是一个使用 selenium 将视频上传到 YouTube 的 python 解决方案:

from selenium import webdriver
driver = webdriver.Firefox()
driver.implicitly_wait(5) # Wait up to 5 secs before throwing an error if selenium cannot find the element (!important)
driver.get("https://www.youtube.com/upload")
elem = driver.find_element_by_xpath("//input[@type='file']")
elem.send_keys("C:\\full\\path\to\\video.mp4"); # Window$
#elem.send_keys("/full/path/to/video.mp4"); # Linux

注意事项:
1 - 聪明点,慢慢来,但一定要走;
2 - YouTube 每天最多上传 50 个,但第一天是 100 个;
3 - 截至 2019 年,youtube api 每天只能上传 5 个视频(◔ _◔)

关于python - 如何通过 selenium webdriver python 将文件上传到 youtube?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31086693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com