Télécharger un fichier

s_ouamou Messages postés 17 Date d'inscription jeudi 10 juin 2004 Statut Membre Dernière intervention 24 novembre 2004 - 16 nov. 2004 à 18:44
s_ouamou Messages postés 17 Date d'inscription jeudi 10 juin 2004 Statut Membre Dernière intervention 24 novembre 2004 - 19 nov. 2004 à 18:53
mon but c'est de télécharger un fichier texte ou bat à partir d'un site web.
ce fichier contiendra des données que je vais les traiter par la suite et mettre dans un tableau.

je vous remercie par avance

4 réponses

Utilisateur anonyme
16 nov. 2004 à 18:52
salut, tu peux utiliser une connection FTP par exemple
a+

A.C.I.V.E SARL
Automatismes Conception Informatique Vidéo Electronique
0
cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
16 nov. 2004 à 19:19
dim Fichier as string
Fichier=HttpReadPage("http://mapage.com")

Public Const INTERNET_OPEN_TYPE_PRECONFIG  As Long = 0
Public Const INTERNET_OPEN_TYPE_DIRECT     As Long = 1
Public Const INTERNET_OPEN_TYPE_PROXY      As Long = 3
Public Const HTTP_QUERY_CONTENT_LENGTH     As Long = 5
Public Const INTERNET_FLAG_RELOAD          As Long = &H80000000

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Public Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer
Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, sOptional As Any, ByVal lOptionalLength As Long) As Integer
Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Public Declare Function InternetQueryDataAvailable Lib "wininet.dll" (ByVal hFile As Long, lpdwNumberOfBytesAvailable As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long

Function HttpReadPage(ByVal Url As String) As String
    Dim vBuff  As String
    Dim vhOpen As Long
    Dim vhUrl  As Long
    Dim vSize  As Long
    Dim vRet   As Long
    vhOpen = InternetOpen("Mozilla/4.0", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    If vhOpen Then
        vhUrl = InternetOpenUrl(vhOpen, Url, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
        If vhUrl Then
            If InternetQueryDataAvailable(vhUrl, vSize, 0, 0) Then                If (vSize 0) Then vSize 4096
                vBuff = String(vSize, 0)
                Do
                    InternetReadFile vhUrl, vBuff, vSize, vRet
                    If (vRet = 0) Then Exit Do
                    HttpReadPage = HttpReadPage & Left$(vBuff, vRet)
                Loop
            End If
            InternetCloseHandle vhUrl
        End If
        InternetCloseHandle vhOpen
    End If
End Function


@+

E.B.
0
s_ouamou Messages postés 17 Date d'inscription jeudi 10 juin 2004 Statut Membre Dernière intervention 24 novembre 2004
19 nov. 2004 à 18:48
merci bcp,

moi j'ai proposé d'utiliser FTP mais on a refusé vue que le serveur FTP peut etre attaqué de l'extérieur.

est ce que t'as une idée sur le téléchargement d'un fichier texte par le HTTP.

merci d'avance
0
s_ouamou Messages postés 17 Date d'inscription jeudi 10 juin 2004 Statut Membre Dernière intervention 24 novembre 2004
19 nov. 2004 à 18:53
merci

est ce que j'utilise ce code dans un module de classe et dans la feuille "HTTP" je lance la session.

svp montre moi comment faire
0
Rejoignez-nous