[VB.NET 2005]Runescape World Parser

A place to discuss development on the Microsoft .NET framework platform utilizing languages such as C#, Visual Basic, J# and Managed C++

Moderators: IRC Operators, Support Team

[Mitchell]
Newbie
Newbie
Posts: 3
Joined: Thu Jul 31, 2008 6:53 am

[VB.NET 2005]Runescape World Parser

Postby [Mitchell] » Sun Aug 03, 2008 5:25 am

Comes in 2 parts, first is the function that downloads the world page and uses regular expressions to download the world information in the format "[World],[f2p/p2p],[status],[activity],[lootshare enabled],["world"],[players],[location]" and then returns it as a regularexpression.matchcollection.

The second part parses the info and adds it to a listview object.

Screenshot:

http://img397.imageshack.us/img397/6042/runescapeworldsrm1.jpg

Requires a listview object named lvWorlds and a button named btnWorlds

Code: Select all

    Private Sub btnWorlds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWorlds.Click
        lvWorlds.Items.Clear()
        Dim d As reg.Match
        Dim info As reg.MatchCollection
        Dim params() As String
        Dim x As ListViewItem
        Dim objColor As Color
        info = GetWorldsInfo()
        MsgBox(info.Count)
        For Each d In info
            params = Split(d.Value, ",")
            If params(1) Then
                objColor = Color.Gold
                params(1) = "P2P"
            Else
                objColor = Color.Silver
                params(1) = "F2P"
            End If
            Select Case params(7)
                Case 0
                    params(7) = "US WEST 1"
                Case 1
                    params(7) = "US WEST 2"
                Case 2
                    params(7) = "US WEST 3"
                Case 3
                    params(7) = "UK 2"
                Case 4
                    params(7) = "US WEST 5"
                Case 5
                    params(7) = "UK 1"
                Case 6
                    params(7) = "CANADA 2"
                Case 7
                    params(7) = "US EAST 2"
                Case 8
                    params(7) = "US CENTRAL 3"
                Case 9
                    params(7) = "US CENTRAL 2"
                Case 10
                    params(7) = "NETHERLANDS 1"
                Case 11
                    params(7) = "US CENTRAL 1"
                Case 12
                    params(7) = "US WEST 4"
                Case 13
                    params(7) = "US EAST 1"
                Case 14
                    params(7) = "US EAST 3"
                Case 15
                    params(7) = "AUSTRALIA"
                Case 16
                    params(7) = "SWEDEN"
                Case 17
                    params(7) = "CANADA 1"
                Case 18
                    params(7) = "FINLAND"
                Case 19
                    params(7) = "NETHERLANDS 2"
                Case 20
                    params(7) = "US CENTRAL 2"
                Case 21
                    params(7) = "UNITED STATES 1"
                Case 22
                    params(7) = "UNITED STATES 2"
                Case 23
                    params(7) = "UNITED STATES 3"
            End Select
            params(3) = params(3).Replace(Chr(34), "")
            x = lvWorlds.Items.Add(params(1))
            x.BackColor = objColor
            With x.SubItems
                .Add(params(0))
                .Add(params(6))
                .Add(params(3))
                .Add(params(7))
            End With
        Next
    End Sub
    Private Function GetWorldsInfo() As reg.MatchCollection
        Static wc As New Net.WebClient
        Dim html As String
        html = wc.DownloadString("http://www.runescape.com/slj.ws?order=WLPAM")
        Return reg.Regex.Matches(html, "[0-9]+,[01],[0-9],""(\-|[a-z\s\!-/2]+)"",(true|false),""world[0-9]+"",[0-9]+,[0-9]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
    End Function


Sorry for the lack of comments, but most of it is pretty self explanatory if you read it.
VB.NET Programmer
mSL Noob
dozy-ben
Newbie
Newbie
Posts: 17
Joined: Wed Jun 11, 2008 10:26 am

Postby dozy-ben » Sun Aug 03, 2008 6:12 am

Edited your screenshot link to work, good effort. :)
Runey676
User
User
Posts: 238
Joined: Wed May 16, 2007 1:32 am
Location: A computer of some sort
Contact:

Postby Runey676 » Sun Aug 03, 2008 6:49 pm

Very nice, but you might want people to know, if they're going to try this, that they have to make the listview columns yourself and add some settings for it to look like the screenshot.

Return to “.NET”

Who is online

Users browsing this forum: No registered users and 1 guest