Je suis entrain de tester un téléchargement de mp3 de cette URL :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
http://promodj.com/download/4126268/Chris%20Parker%20-%20Life%20MIX%20%282011%20-%202013%29%20%28promodj.com%29.mp3
, mais je rencontre une erreur Accès refusé à la ligne N°26, sachant que l'url marche dans tous les navigateurs ?
quelqu’un ici peut m'expliquer ou est mon erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Option Explicit
Dim Titre,objFSO,Ws,objXMLHTTP,PathScript,Tab,URL,strHDLocation,objADOStream,Command,Start,File,ExempleURL
Titre = "Downloading MP3 by © Hackoo 2013"
Set objFSO = Createobject("Scripting.FileSystemObject")
PathScript = objFSO.GetParentFolderName(wscript.ScriptFullName) 'Chemin ou se localise le Vbscript
Set Ws = CreateObject("wscript.Shell")
ExempleURL = "http://promodj.com/download/4126268/Chris%20Parker%20-%20Life%20MIX%20%282011%20-%202013%29%20%28promodj.com%29.mp3"
URL = InputBox("Tapez ou collez l'URL dans le champ de saisie Exemple : "&Dblquote(ExempleURL)&"",Titre,ExempleURL)
URL = Escape(URL)
msgBox URL
If URL = "" Then WScript.Quit
Tab = split(url,"/")
File = Replace(Tab(UBound(Tab)),"28","")
File = Replace(Tab(UBound(Tab)),"29","")
File = Replace(Tab(UBound(Tab)),"20","")
File = Replace(Tab(UBound(Tab))," ","_")
File = Replace(Tab(UBound(Tab)),"-","_")
File = Replace(Tab(UBound(Tab)),"(","_")
File = Replace(Tab(UBound(Tab)),")","_")
File = Replace(Tab(UBound(Tab)),"%","_")
Msgbox  "The download of " & Dblquote(File) & " is in progress ! ",64,"The download of " & Dblquote(File) & " is in progress ! "
strHDLocation = PathScript & "\" & File
Set Ws = CreateObject("WScript.Shell")
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET",UnEscape(URL),false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
    Set objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open
    objADOStream.Type = 1 'adTypeBinary
    objADOStream.Write objXMLHTTP.ResponseBody
    objADOStream.Position = 0    'Set the stream position to the start
    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
    objADOStream.SaveToFile strHDLocation
    objADOStream.Close
    Set objADOStream = Nothing
End If
Set objXMLHTTP = Nothing 
 
MsgBox "The Download of " & Dblquote(Tab(UBound(Tab))) & " is finished ! ",64,"The Download of " & Dblquote(Tab(UBound(Tab))) & " is finished ! "
Command = "Cmd /c start explorer "& Dblquote(strHDLocation) &" "
Start = Ws.Run(Command,0,False)
 
Function Dblquote(str)
    Dblquote = chr(34) & str & chr(34)
End Function