有没有办法用Python控制windows?
我正在尝试创建一个将文件上传到网站的脚本。我无法控制该网站,因此必须通过单击和键入来上传文件。
又名,
- 等待上传窗口弹出,输入
- 文件名/路径,
- 单击“打开”或“上传”(或其他)按钮,
因为该窗口是操作系统的一部分(不是浏览器窗口),所以我无法使用它来控制它硒或类似的东西(据我所知。如果我错了,请告诉我)。这意味着我需要脚本来执行此操作。
我已经让它在 Windows 上运行(用 AutoIt 制作),但是,我还需要它在 Unix 系统 (Linux) 上运行。
所以我想问一下,有没有办法用Python之类的东西来做到这一点?如果我可以制作一个可以在两者上运行的脚本,那就太棒了(AutoIt 仅适用于 Windows)。
我了解 Java、Python 和 AutoIt,但如果这些都做不到,我可以学习其他东西。
谢谢。
编辑:
好的,显然使用 HTTP POST 是执行此操作的方法,但是我不确定如何执行此操作。我将对此进行更多研究。感谢@Chrules 提醒我注意这一点。
I'm trying to create a script that will upload a file to a website. I have no control of the website so the file has to be uploaded via clicking and typing.
Aka,
- wait for upload window to pop up
- type name/path of file
- click "Open" or "upload" (or whatever) button
Because the window is part of the OS (not a browser window), I can't control it with Selenium or something like that (as far as I know. Plz let me know if I am wrong). This means I need the script to do this.
I already have it working for Windows (made it with AutoIt) however, I also need it to run on Unix systems (Linux).
So I'm asking, is there a way to do it with Python or something? If I can make one script that will run on both, that would be awesome (AutoIt is Windows-only).
I have knowledge of Java, Python and AutoIt, but if none of those can do it, I can learn something else.
Thanks.
EDIT:
Ok, so apparently using HTTP POST is the way to do it, however I am not sure how to do this. I'm going to do more research on that. Thx @Chrules for bring this to my attention.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在您想通过 HTTP 请求来完成此操作,Requests 库强烈推荐。
就是这么简单:
Now that you want to do it via an HTTP request, the Requests library is highly recommended.
It is really that simple: