Mad*_*bit 5 python selenium selenium-chromedriver selenium-webdriver
无法弄清楚如何在那里上传文件?需要拖拽或直接通过对话框选中
\n\n“看来您无法使用典型的 sendkeys 方法在 YouTube 上上传文件”
\n
4 年后...
\n@chandan-nayak:你可以,这里有一个使用 selenium 将视频上传到 YouTube 的 Python 解决方案:
from selenium import webdriver\ndriver = webdriver.Firefox()\ndriver.implicitly_wait(5) # Wait up to 5 secs before throwing an error if selenium cannot find the element (!important)\ndriver.get("https://www.youtube.com/upload")\nelem = driver.find_element_by_xpath("//input[@type='file']")\nelem.send_keys("C:\\\\full\\\\path\\to\\\\video.mp4"); # Window$\n#elem.send_keys("/full/path/to/video.mp4"); # Linux\nRun Code Online (Sandbox Code Playgroud)\n注:
\n1 - 聪明一点,缓慢而坚定;
\n2 - YouTube 每天最多上传 50 次,但第一天为 100 次;
\n3 - 截至 2019 年,youtube api 仅限每天上传 5 个视频(\xe2\x97\x94 _\xe2\x97\x94)
根据此处的答案:stackoverflow 看起来您无法使用典型的 sendkeys 方法在 YouTube 上上传文件。
正如@Arran 在评论部分所说 -
Selenium 无法处理文件上传对话框。YouTube 使用 HTML5 输入字段,而 Selenium 根本不处理 HTML5 元素。正如我所说,Selenium 无法支持这一点。硒在这里不起作用
您应使用youtube提供的API
| 归档时间: |
|
| 查看次数: |
2629 次 |
| 最近记录: |