Python 調用IDM下載工具下載鏈接文件


Python 調用IDM下載工具下載鏈接文件

IDM(Internet DownloadManager) 可以在Windows通過命令行參數啟動,以及通過提供參數開始下載。需要添加大量下載鏈接時,使用腳本完成更為更為省時省力。下面為用 Python 調用IDM下載鏈接的兩種方法。

IDM命令行參數

  1. 使用os.system()

    import os
    
    def IDMdownload(DownUrl, DownPath, FileName):
        IDMPath = "C:\\Program Files (x86)\\Internet Download Manager\\"
        os.chdir(IDMPath)
        IDM = "IDMan.exe"
        command = ' '.join([IDM, '/d', DownUrl, '/p', DownPath, '/f', FileName, '/a', '/s'])
        os.system(command)
        
    
  2. 使用subprocess

    from subprocess import call
    def IDMdown(DownUrl, DownPath, FileName):
        IDMPath = "C:\\Program Files (x86)\\Internet Download Manager\\"
        os.chdir(IDMPath)
        IDM = "IDMan.exe"
        call([IDM, '/d', DownUrl, '/p', DownPath, '/f', FileName, '/a'])
        call([IDM, '/s'])
        
    
         IDMPath 為IDM安裝路徑
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM