在 Python 中使用 Selenium 上传文件
是否可以在Python脚本中使用selenium上传文件附件?
Is it possible to upload file attachment with selenium in Python script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以在Python脚本中使用selenium上传文件附件?
Is it possible to upload file attachment with selenium in Python script?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
可以通过以下方式完成:
It can be done via:
上传文件的一个简单方法是使用 pyautogui。可以通过pip安装pyautogui
A simple method to upload files is by using pyautogui. You can install pyautogui through pip
现在,如果您在 Windows 中,文件路径使用反斜杠。为了避免出现问题,使用双反斜杠! C:\ \Users\ ****\ \Desktop\ \1.jpg,不带空格。
附言。我知道它是 4 年前的,但我已经尝试弄清楚这一点有一段时间了,有人可能会发现这很有用......
Now if you are in windows path to file uses backslash. To avoid issues use double backslashes! C:\ \Users\ ****\ \Desktop\ \1.jpg without spaces.
PS. I know its a from 4 years ago but I have been trying to figure this out for some time and someone might find this usefull...
使用 selenium 将视频上传到 YouTube 的 Python 解决方案。
注释:
1 - 聪明一点,缓慢但坚定地走;
2 - YouTube 每天最多上传 50 次,但第一天为 100 次;
3 - 截至 2019 年,youtube api 仅限上传 5 个视频 (◔ _◔)
Python solution to upload a video to YouTube using selenium.
Notes:
1 - Be smart, go slowly but surely;
2 - YouTube max uploads per day is 50, but on the first day is 100;
3 - As of 2019, youtube api is limited to 5 video uploads (◔ _◔)
尝试一下基于 ytb_up 的 selenium。
灵感来自一堆自动上传 YouTube 视频库
https://github.com/wanghaisheng/ytb-up
您可能需要
功能自动检测是否需要代理
2. cookie 支持
同一 google 帐户下的多个频道
3.安排时间发布
您可以明确指定每个视频的日期和时间,也可以设置发布策略和每日公众数量,例如,每日数量为4,您有5个视频,那么前4个将在发布后1天发布上传日期,另外1个为上传日期后2天
4.修复谷歌账户验证
give it a shot ytb_up based selenium.
inspired from bunch of auto upload youtube video library
https://github.com/wanghaisheng/ytb-up
features YOU MAY NEED
auto detect whether need a proxy
2. cookie support
for those multiple channels under same google account
3. schedule time publish
you can explictly specify a date and time for each video or you can set publish policy and daily public count,for example,daily count is 4,you got 5 videos,then first 4 will be published 1 day after the upload date ,the other 1 will be 2 days after the upload date
4. fix google account verify
很简单,用IDE录制即可。上传命令正在运行
it is quite simple, just record it using IDE. Upload command is working
如果页面上有一个带有文件输入的表单,我认为在输入中填充值并使用selenium的python api提交表单很简单。您可以在文档页面上找到一些示例代码
If there is a form with file input on the page, I think it's straightforward to fill value in the input and submit the form with python api of selenium. You can find some sample code on the document page