Parse Text file from website RRS feed

  • Question

  • how can I parse a text file from a web site/

    Sunday, August 7, 2016 1:39 AM


  • how can I parse a text file from a web site/

    I guess that depends on your definition, but if you're talking about "reading" the text (and returning it if there's not a problem) and it's HTTP, you might start with this:

    Imports System.IO
    Imports System.Net

    Private Function ReturnTextFromURL(ByVal url As String) As String Dim retVal As String = "" Try Dim request As WebRequest = WebRequest.Create(url) Using response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse) Using dataStream As Stream = response.GetResponseStream Using reader As New StreamReader(dataStream) Dim responseFromServer As String = reader.ReadToEnd() retVal = responseFromServer End Using End Using End Using Catch ex As Exception retVal = "" End Try Return retVal End Function

    Be sure to test that the return value isn't null or empty.

    I hope that helps. :)

    Some people succeed because they were destined to, but most people succeed because they were determined to.

    Sunday, August 7, 2016 2:00 AM