Re: Get Body of an Http Reply Using WebResponse...

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: K. Giagias (Giagias_at_discussions.microsoft.com)
Date: 07/19/04


Date: Mon, 19 Jul 2004 08:24:02 -0700

I have to check this...
As I understand I can Supply the </head>*</html> in the regex patern and the match string would be the "WROND DATA..."

I was looking for something else like loading the output into a html object or something and then geting the value of an inner text or something...

"Greg Burns" wrote:

> If you have your output in a string (say inputstring), I would look at using
> a regular expression to grab what your need.
>
> Dim r As New Regex("(.*)") <<< put in your regex here (the hard part) :^)
>
> Dim m As Match
> m = r.Match(inputstring)
> If m.Success Then
> outputstring = m.Groups(1).Value
> End If
>
> Greg
>
> "K. Giagias" <K. Giagias@discussions.microsoft.com> wrote in message
> news:EEA005DB-77F5-4DB2-A580-12B6EE4A35C3@microsoft.com...
> > Hello all,
> >
> > I'm kind of stuck in a matter that I'm not so expienced...
> >
> > I have a Windows App that hits a web page (POST)
> >
> > The code is something like this
> >
> > Dim siteUri As New System.Uri(url) ' it is a parameter in the function
> > Dim webRequest As System.Net.WebRequest =
> System.Net.WebRequest.Create(siteUri)
> > Dim urlProxy As New Uri("http://10.11.21.153")
> > webRequest.Proxy = New System.Net.WebProxy(urlProxy)
> > CredUser = "username"
> > CredPass = "userpass"
> > CredDomain = "userdomain"
> > webRequest.Proxy.Credentials = New NetworkCredential(CredUser, CredPass,
> CredDomain)
> > Dim webResponse As System.Net.WebResponse = webRequest.GetResponse()
> > Dim ReceiveStream As Stream = webResponse.GetResponseStream()
> > Dim sr As New StreamReader(ReceiveStream)
> > page = sr.ReadToEnd
> > MsgBox(page)
> > ReceiveStream.Close()
> > sr.Close()
> > webResponse.Close()
> >
> > The result is the Html source code. Something like this:
> > <html>
> > <head>
> > <title>PageTitle</title>
> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > </head>
> > WRONG DATA...
> > </html>
> >
> > From the above I only need to read the body. "WRONG DATA..."
> >
> > My question is: How can I extract the text body of the Html source from
> the StreamReader or the "page" string variable.
> >
> > Right now I'm working on a string parser but I don't think that this is
> the best way of doing it...
>
>
>