Adblock breaks this site

Grabbing things of a website such as runescape?

Discussion in 'Programming General' started by ViruZ3, May 9, 2008.

  1. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    How do i grab things using Visual Basic 2008? People have Grand Exchange Parsers... How do i make one of those? Please help.
     
  2. halojunkie

    halojunkie Active Member

    Joined:
    Dec 17, 2005
    Posts:
    232
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    Inet control?
     
  3. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    How do i implement this into my program?
     
  4. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    Grabbing things of a website such as runescape?

    Never use the INet control in .NET languages. Use the WebClient class instead:
    Code:
    ''' <summary>Download the content (Html) code of a webpage.</summary>
    ''' <param name="Url">The Url of the webpage to download.</param>
    Public Function DownloadString(ByVal Url As String) As String
        Static Client As New System.Net.WebClient()
        Return Client.DownloadString(Url)
    End Function 
     
  5. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    Oh i have that... BUT im trying to get each line parsed out. Heres my code:
    Code:
            NameBox.Text.Replace(" ", "_")
            Label1.Text = "Retriving hiscore data..."
            Dim UName As String = NameBox.Text
            Dim HiData As String = "http://hiscore.runescape.com/index_lite.ws?player=" & UName
            Dim WebC As New Net.WebClient()
            Dim UData = WebC.DownloadString(HiData)
            Dim Skills = 0
            For Each Line As String In HiData.Split(vbNewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
                Skills += 1
                TextBox1.Text = Skills
            Next
            Dim EditData = UData.Replace("-1", "N/A")
            Label1.Text = EditData
    
    See the Skills count is supposed to add 1 for each line but its returning Skills = 1 for the hiscore data.
     
  6. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    Grabbing things of a website such as runescape?

    You are splitting the Url of the hiscores page, not the downloaded data.
    Replace HiData.Split with UData.Split, and it should work.
     
  7. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    I've already fixed that... :) but how to i get individual lines out of the text i downloaded? First line says 352687,1306,13143196 but how do i dim the numbers between the commas?
     
  8. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    Grabbing things of a website such as runescape?

    You can convert strings to numbers with the function Integer.Parse.
    Here is an example for getting those stats:
    Code:
    For Each Line As String In UData.Split(vbNewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
        Dim SplitData = Line.Split(",")
        Dim Rank = Integer.Parse(SplitData(0))
        Dim Level = Integer.Parse(SplitData(1))
        Dim Experience? = If(SplitData.Length = 3, Integer.Parse(SplitData(2)), Nothing)
    Next 
    Experience? means that it can be nothing, so if there is no experience listed Experience will be Nothing instead of 0.
     
  9. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    And this will go through all the lines? Im trying to add the data to textboxes. How do i switch lines?
     
  10. ViruZ3

    ViruZ3 Member

    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0
    Grabbing things of a website such as runescape?

    This is my code so far:
    Code:
            NameBox.Text.Replace(" ", "_")
            Dim UName As String = NameBox.Text
            Dim HiData As String = "http://hiscore.runescape.com/index_lite.ws?player=" & UName
            Dim WebC As New Net.WebClient()
            Dim UData = WebC.DownloadString(HiData)
            Dim Skills = 0
            For Each Line As String In UData
                Dim EditData = UData.Replace("-1", "N/A")
                Dim SplitData = UData.Split(",")
                Dim Rank = Integer.Parse(SplitData(0))
                Dim Level = Integer.Parse(SplitData(1))
                Dim Experience = (SplitData(2))
                Label2.Text = "Rank: " + Rank.ToString + " Total Level: " + Level.ToString + " Total XP: " + Experience.ToString
                Me.Text = "Hiscore Grabber (" + UName + ": TL:" + Level.ToString + ")"
            Next
    
    Im trying to parse out the rest of the skills not just the player rank, total level and total experiance. Can anyone help me?
     
< Help conection | Help with variable? ;[ >


 
 
Adblock breaks this site