Retreive a CSV file from website??

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

In VB6 I used MSXML to retreive a CSV file from a web site so I could
parse it and save to a Db. What is the best way to accomplish this
with VB.NET?

VB6 Code:

Dim HTTPObj As MSXML2.XMLHTTP

sURL = "http://download.lender.com/rates/BROKER.CSV"
Set HTTPObj = New MSXML2.XMLHTTP
HTTPObj.open "get", sURL, False
HTTPObj.Send
sPage = HTTPObj.responseText
Lines = Split(sPage, vbLf)

Thank you,

Don
Redmond, WA
 
Hi Don,

The following should do the trick

Regards,
Fergus

<code>
Public Function GetTextFrom (sUrl As String) As String
Dim oRequest As WebRequest = WebRequest.Create(sUrl)
Dim oResponse As HttpWebResponse _
= DirectCast (oRequest.GetResponse(), HttpWebResponse)

Dim oStream As New StreamReader (oResponse.GetResponseStream)
Dim sText As String = oStream.ReadToEnd

oStream.Close
oResponse.Close()

Return sText
End Function
</code>
 
Back
Top