[Code] Parse all runescape worlds from website!

Discussion in 'Programming General' started by speljohan, Mar 13, 2007.

[Code] Parse all runescape worlds from website!
  1. Unread #1 - Mar 13, 2007 at 12:45 PM
  2. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    [Code] Parse all runescape worlds from website!

    Well, at least it used to be able to do it. This is the code i used to parse runescape website before they made an update and turned it all into javascript. I've parsed the new one, but i'm giving out my old code in an attempt to teach you all about string manipulation. Here it is:
    Code:
        Dim html_parser As New MIL.Html.HtmlDomainTreeParser()
        Dim html_document As New MIL.Html.HtmlDocument
        Dim html_node As MIL.Html.HtmlNode
        Dim html_nodelist As New MIL.Html.HtmlNodeCollection
    Code:
        Public Sub grabWorldsOld()
    
            Dim tmp() As String
            Dim worldType As String = Nothing
            Dim worldPrefix As String = Nothing
            Dim worldNumber As String = Nothing
    
            If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\worldlist.lst") Then
                My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\worldlist.lst")
            End If
    
            Dim out As New IO.StreamWriter(My.Application.Info.DirectoryPath & "\worldlist.lst")
            Dim htmlgrabber As New Net.WebClient()
            html_document = html_parser.Parse(htmlgrabber.DownloadString("http://www.runescape.com/sl.ws?lores.x=420&plugin=0&order=WLPM"))
            html_nodelist = html_document.Nodes.FindAllElements(True)
    
            For Each html_node In html_nodelist
                If html_node.HTML.Contains("<tr>") And html_node.HTML.Contains("</tr>") And Not html_node.HTML.Contains("</div>") And Not html_node.HTML.Contains("<table") Or html_node.HTML.Contains("<tr class=" & Chr(34) & "r2" & Chr(34) & ">") And html_node.HTML.Contains("</tr>") And Not html_node.HTML.Contains("</div>") And Not html_node.HTML.Contains("<table") Then
                    'Getting World Number
                    worldNumber = html_node.HTML.Substring(InStr(html_node.HTML(), "World") + 5)
                    tmp = worldNumber.Split("<")
                    worldNumber = tmp(0).Trim()
                    tmp = Nothing
    
                    'Getting World Prefix
                    If html_node.HTML.Contains("http") Then
                        tmp = html_node.HTML.Split(".")
                        tmp = tmp(0).Split("/")
                        worldPrefix = tmp(2)
                        tmp = Nothing
                    Else
                        worldPrefix = "Full"
                    End If
    
    
                    'Getting World Type
                    If html_node.HTML.Contains("<td class=" & Chr(34) & "m" & Chr(34) & ">") Then
                        worldType = "members"
                    ElseIf html_node.HTML.Contains("<td class=" & Chr(34) & "f" & Chr(34) & ">") Then
                        worldType = "free"
                    End If
                    out.WriteLine(worldNumber & "," & worldPrefix & "," & worldType)
                End If
            Next
            out.Close()
            MsgBox("Success! All worlds have been parsed.")
        End Sub
    To use that html parser, you will need to reference the file i've attached.

    Enjoy:)
     

    Attached Files:

< BjorkScape Reborn! Unique Client!! | I wanted to make a world switcher in VB .NET 2005 >

Users viewing this thread
1 guest


 
 
Adblock breaks this site