Home All Groups Group Topic Archive Search About

Retrieving a webpage source HTM and checking for a string thereinL?

Author
12 Jan 2006 10:36 PM
me
Hi all,

Can anyone give me any pointers on how to do the following in VB.NET?

Basically, I want a procedure that will take a web URL and a string as
parameters, e.g. www.microsoft.com and 'Bill Gates'

I want the procedure to pull that page from the web, check for the existence
of 'Bill Gates' and return either true or false depending on whether or not
the string can be found.

I suppose all I need to know is - what is an effecient way to pull the HTML
source from any URL?

Help appreciated :)

Author
12 Jan 2006 10:54 PM
Terry Olsen
How about this?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Private Function FindBill as Boolean

Dim hreq As HttpWebRequest = _
         HttpWebRequest.Create("http://www.microsoft.com")

Dim hres As HttpWebResponse = hreq.GetResponse
Dim sr As New StreamReader(hres.GetResponseStream)
Dim tmpRes As String = UCase(sr.ReadToEnd)
sr.Close()
hres.Close()

If tmpRes.IndexOf("Bill Gates") >= 0 Then
   Return True
Else
   Return False
End If

End Function

*** Sent via Developersdex http://www.developersdex.com ***
Author
12 Jan 2006 10:58 PM
Herfried K. Wagner [MVP]
"me" <c**@notvalid.com> schrieb:
> what is an effecient way to pull the HTML source from any URL?

Check out the function at
<URL:http://dotnet.mvps.org/dotnet/code/net/#InternetLoadFile>.  You can use
'InStr' to check if a string contains a certain substring.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
12 Jan 2006 11:03 PM
Ken Tucker [MVP]
Hi,

http://www.vb-tips.com/default.aspx?ID=541adf13-d9c0-435c-893f-56dbb63fdf1c

Ken
--------------------------
Show quoteHide quote
"me" <c**@notvalid.com> wrote in message
news:43c6d9cf$0$23285$db0fefd9@news.zen.co.uk...
> Hi all,
>
> Can anyone give me any pointers on how to do the following in VB.NET?
>
> Basically, I want a procedure that will take a web URL and a string as
> parameters, e.g. www.microsoft.com and 'Bill Gates'
>
> I want the procedure to pull that page from the web, check for the
> existence
> of 'Bill Gates' and return either true or false depending on whether or
> not
> the string can be found.
>
> I suppose all I need to know is - what is an effecient way to pull the
> HTML source from any URL?
>
> Help appreciated :)
>
>
Author
12 Jan 2006 11:48 PM
me
Show quote Hide quote
"me" <c**@notvalid.com> wrote in message
news:43c6d9cf$0$23285$db0fefd9@news.zen.co.uk...
> Hi all,
>
> Can anyone give me any pointers on how to do the following in VB.NET?
>
> Basically, I want a procedure that will take a web URL and a string as
> parameters, e.g. www.microsoft.com and 'Bill Gates'
>
> I want the procedure to pull that page from the web, check for the
> existence
> of 'Bill Gates' and return either true or false depending on whether or
> not
> the string can be found.
>
> I suppose all I need to know is - what is an effecient way to pull the
> HTML source from any URL?
>
> Help appreciated :)
>
>


Cheers to all of you - worked a treat :)