All pastes #905460 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-15 20:00 UTC
rendered paste body
Imports System.Net
Imports System.IO
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Text.RegularExpressions
Public Class Form1
    Private Sub fetchbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fetchbutton.Click
        Try
            fetchbutton.Enabled = False
            Dim RuneScape As New WebClient()
            Dim socket As Stream = RuneScape.OpenRead("http://www.runescape.com/title.ws")
            Dim read As New StreamReader(socket)
            Dim sockread As String
            Dim lol As Boolean = True
            While lol
                sockread = read.ReadLine
                If sockread.Contains("There are") Then
                    lol = False
                    playerbox.Text = sockread
                    socket.Close()
                End If
            End While
            fetchbutton.Enabled = True
        Catch
            playerbox.Text = "Error try again..."
            fetchbutton.Enabled = True
        End Try
    End Sub

    Private Sub getnews_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getnews.Click
        Try
            getnews.Enabled = False
            Dim RuneScape As New WebClient()
            Dim socket As Stream = RuneScape.OpenRead("http://www.runescape.com/title.ws")
            Dim read As New StreamReader(socket)
            Dim sockread As String
            Dim lol As Boolean = True
            While lol
                sockread = read.ReadLine
                If sockread.Contains("newsdate") Then
                    Dim lol1() As String = Split(sockread, "</span>")
                    newsname.Text = nohtml(lol1(0))
                    newsdate.Text = nohtml(lol1(1))
                End If
                If sockread.Contains("text-align: justify; vertical-align: top;") Then
                    lol = False
                    body.Text = nohtml(sockread)
                    socket.Close()
                End If
            End While
            getnews.Enabled = True
        Catch
            MsgBox("Error try again...")
            getnews.Enabled = True
        End Try
    End Sub
    Public Function nohtml(ByVal str As String) As String
        Return Regex.Replace(str, "<[^>]+>", "")
    End Function
End Class