| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 | Function Get_request(ByVal url As String, Optional ByVal proxy As String = Nothing, Optional ByVal proxyport As Integer = Nothing) As String
        Dim readstr As IO.StreamReader 'on crée un objet streamreader
        Try
            If proxy <> "" Then
                Dim hproxy As WebProxy
                hproxy = New WebProxy(proxy, proxyport)
                WebRequest.DefaultWebProxy = hproxy
            End If
 
 
            Dim hwebrequest As System.Net.WebRequest = System.Net.WebRequest.Create(url) 'on crée la requete web
            'hwebrequest.
            Dim hwebresponse As System.Net.WebResponse = hwebrequest.GetResponse 'on crée un objet de reponse a notre requete
            readstr = New IO.StreamReader(hwebresponse.GetResponseStream) 'on redefini notre streamreader avec la reponse à la requete en argument
            Return readstr.ReadToEnd() 'on renvoie l'ensemble du resultat
            readstr.Close() 'on ferme l'objet
 
        Catch ex As Exception
 
            Return ex.Message.ToString ' en cas d'erreur, on renvoie la description de l'erreur
            readstr.Close()
 
        End Try
 
    End Function | 
Partager