如何判断 Firefox 何时完成下载?
我正在编写一个程序,需要知道 Firefox 何时完成下载。我不是在寻找黑客,比如在下载目录中查看文件大小是否仍在变化,因为所有类似的解决方案都可能会导致竞争条件。我希望从 Firefox 本身接收某种编程信号。我相信通过创建一个 Firefox 插件可以实现这一点,但由于我以前从未编写过插件,因此在重新发明轮子之前,我希望使用现有的解决方案(如果有)。
我正在编写的程序目前正在使用 Selenium 来运行 Firefox,因此如果 Selenium 有您知道的针对此问题的现有解决方案,那也很酷。
非常感谢!
I'm writing a program that needs to know when Firefox completes a download. I'm not looking for a hack, like looking in the download directory to see if the file size is still changing, because all solutions like that will probably lend themselves to race conditions. I'm looking to receive some kind of programmatic signal from Firefox itself. I believe this would be possible by creating a Firefox Addon, but since I've never written an Addon before, I'm looking to use an existing solution if there is one, before I go re-inventing the wheel.
The program I'm writing is currently using Selenium to run Firefox, so if Selenium has an existing solution to this problem that you know of, that would be cool too.
Thanks a bunch!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许我误解了你的意思,但我不确定你为什么要启动 Firefox 只是为了下载文件。无论如何,您可以将 下载进度侦听器 添加到 下载管理器。甚至还有一个监控下载的示例。
Maybe I've misunderstood you, but I'm not sure why you'd want to launch Firefox just to download a file. Anyway, you can add a download progress listener to the download manager. There's even an example of monitoring downloads.