使用Python调用IDM(互联网下载管理器)API

1 投票
2 回答
7163 浏览
提问于 2025-04-17 23:30

我想通过Python使用IDM的接口,但我完全不知道该怎么做。http://www.internetdownloadmanager.com/support/idm_api.html

有人能帮帮我吗?我甚至不知道用Python是否能做到这一点。

2 个回答

2

更新IDM(Windows)的文档:

你可以在这里找到相关信息:https://pypi.org/project/idm/

示例代码:

from idm import IDMan

downloader = IDMan()
url = "http://test.com/test.exe"

downloader.download(url, r"c:\DOWNLOADS", output=None, referrer=None, cookie=None, postData=None, user=None, password=None, confirm = False, lflag = None, clip=False)
4

IDM的API好像可以通过Visual Basic来访问,这很好,因为这意味着它支持IDispatch,所以也能在Python中使用。你可以使用comtypes这个库。可以把VB示例当作一个模板来参考:

import comtypes.client as cc
import comtypes

referrer = ""
cookie = ""
postData = ""
user = ""
password = ""
cc.GetModule(["{PUT_UUID_HERE}",1,0])
# not sure about the syntax here, but cc.GetModule will tell you the name of the wrapper it generated
import comtypes.gen.IDManLib as IDMan
idm1 = cc.CreateObject("IDMan.CIDMLinkTransmitter", None, None, IDMan.ICIDMLinkTransmitter2)
idm1.SendLinkToIDM("http://www.internetdownloadmanager.com/idman401.exe",
referrer, cookie, postData, user, password, r"C:\\", "idman401.exe", 0)

撰写回答