IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Problème d'encodage d'URL


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut Problème d'encodage d'URL

    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

  2. #2
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut

    Le est Problème est ici dans cette discussion
    Allez, je vous souhaite un Bon Téléchargement et un bon Mixage et n'oubliez pas les +1
    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
    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"
    'ExempleURL = "http://nerdherd.cilverphox.com/music/Chicane/Easy%20To%20Assemble/05%20-%20Locking%20Down.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 =  Tab(UBound(Tab))
    File = Replace(File,"%20"," ")
    File = Replace(File,"%28","(")
    File = Replace(File,"%29",")")
    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") ' ne marche pas avec MSXML2.XMLHTTP :(
    Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0") 'ça marche avec MSXML2.ServerXMLHTTP.3.0 :)
     
    objXMLHTTP.open "GET", 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(File) & " is finished ! ",64,"The Download of " & Dblquote(File) & " 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

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème d'encodage des url
    Par The Jos dans le forum Langage
    Réponses: 1
    Dernier message: 13/10/2010, 22h19
  2. Problème d'encodage d'url
    Par jc63 dans le forum Apache
    Réponses: 1
    Dernier message: 08/10/2008, 13h32
  3. [URL Rewriting] Problème d'encodage
    Par cootchy dans le forum Apache
    Réponses: 1
    Dernier message: 29/08/2007, 10h00
  4. [AJAX] encodage-decodage URL avec Java et Javascript
    Par alfreedd dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 05/06/2007, 13h45
  5. Problème encodage-decodage URL avec Java et Javascript
    Par alfreedd dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 27/04/2007, 12h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo