How can I download a webpage every 5 hours?

I am trying this code:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=71&lngWId=10

but..

Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tOut.Text = ""
        Dim EPIP As IPEndPoint = New IPEndPoint(Dns.Resolve(tHost.Text).AddressList(0), 80)
        Dim Sck As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        Try
            Sck.Connect(EPIP)
            If Sck.Connected = False Then MsgBox("ERROR:" & vbCrLf & "Could not connect.") : Exit Sub
            Sck.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
            Dim Buffer(1024) As Byte
            Dim ByteCount As Int16 = Sck.Receive(Buffer, Buffer.Length, 0)
            tOut.Text = ASCII.GetString(Buffer, 0, ByteCount)
            Do While ByteCount > 0
                ByteCount = Sck.Receive(Buffer, Buffer.Length, 0)
                tOut.Text &= ASCII.GetString(Buffer, 0, ByteCount)
            Loop
        Catch
            MsgBox(Err.Description)
        End Try
    End Sub

doesn't work for webpage addresses... example:
works: www.fakewebsite.com
does not work: www.fakewebsite.com/website.html

the reason for this is

Visual Basic:
Dim EPIP As IPEndPoint = New IPEndPoint(Dns.Resolve(tHost.Text).AddressList(0), 80)

I guess I could hardcode in the website addres.. but I am not even sure how to do that :/
 
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetPageHTTP("http://www.fakewebsite.com/website.html")
    End Sub


    Public Function GetPageHTTP(ByVal URL As String) As String
        'Ex.: dim s As string = GetPageHTTP("http://www.uol.com.br")
        'Ex.: dim x As string = GetPageHTTP("http://www.microsoft.com/")
        'Ex.: dim x As string = GetPageHTTP("http://www.planet-source-code.com/vb/default.asp?lngWId=10")
        Dim wc As New System.Net.WebClient
        Dim s As System.IO.Stream = wc.OpenRead(URL)
        Dim r As String
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(s, System.Text.Encoding.UTF7, False)
        r = sr.ReadToEnd()
        Return r
    End Function

works!

Now to find out how to find each use of desired string
 
Last edited:
Back
Top