Grabbing things of a website such as runescape?

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

Grabbing things of a website such as runescape?
  1. Unread #1 - May 9, 2008 at 7:39 PM
  2. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    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.
     
  3. Unread #2 - May 10, 2008 at 2:30 PM
  4. halojunkie
    Joined:
    Dec 17, 2005
    Posts:
    232
    Referrals:
    0
    Sythe Gold:
    0

    halojunkie Active Member

    Grabbing things of a website such as runescape?

    Inet control?
     
  5. Unread #3 - May 10, 2008 at 2:32 PM
  6. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    Grabbing things of a website such as runescape?

    How do i implement this into my program?
     
  7. Unread #4 - May 10, 2008 at 3:51 PM
  8. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    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 
     
  9. Unread #5 - May 10, 2008 at 5:10 PM
  10. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    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.
     
  11. Unread #6 - May 10, 2008 at 9:12 PM
  12. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    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.
     
  13. Unread #7 - May 10, 2008 at 9:30 PM
  14. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    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?
     
  15. Unread #8 - May 10, 2008 at 10:08 PM
  16. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    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.
     
  17. Unread #9 - May 10, 2008 at 10:11 PM
  18. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    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?
     
  19. Unread #10 - May 11, 2008 at 6:56 PM
  20. ViruZ3
    Joined:
    May 21, 2007
    Posts:
    55
    Referrals:
    0
    Sythe Gold:
    0

    ViruZ3 Member

    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? ;[ >

Users viewing this thread
1 guest


 
 
Adblock breaks this site