Adblock breaks this site

Hiscores lookup

Discussion in 'Programming General' started by ajp121, Jul 22, 2008.

  1. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    Hey ive managed to get my program to get a users levels but im having trouble getting the xp for each skill as the string joins up the xp with the rank of the next skill in the string, as no commas seperate this like with the level.

    Code:
      
    
        Private Sub btnLookUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLookUp.Click
            Dim name As String = txtUser.Text
            Dim src As String
            Dim skill() As String
            Dim net As New Net.WebClient()
            src = net.DownloadString("http://hiscore.runescape.com/index_lite.ws?player=" + name)
    
            skill = src.Split(",")
            'just to test output:
            Label1.Text = skill(1)
            Label2.Text = skill(2)
    
    
    
            Skills()
        End Sub
    
    skill(2) in the above code gives me the xp of the total level and the rank of attack, i do not know how to seperate these.
    Any help with this would be great, im abit of a newbie.
     
  2. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    Hiscores lookup

    Splitting the page using "," as a delimiter returns this:
    Code:
    71
    2362
    1187618100
    180
    99
    57895409
    113
    99
    53979359
    319
    99
    37727836
    62
    99
    59261315
    76
    99
    36937262
    219
    99
    14132317
    9
    99
    61560194
    5
    99
    200000000
    991
    99
    22079278
    16
    99
    104632668
    159
    99
    27234122
    9
    99
    116979706
    549
    99
    13593918
    73
    99
    17549671
    252
    99
    15759831
    4
    99
    51449695
    309
    99
    13539614
    5
    99
    200000000
    160
    99
    18358162
    116
    99
    19313985
    230
    99
    15967700
    2784
    99
    13145163
    183
    99
    13218287
    1912
    85
    3302608
    2336
    1944
    -1
    -1
    -1
    -1
    -1
    -1
    What's wrong with that? Can't you just use skill(1), skill(2), etc. to get the data you specifically want ?
     
  3. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    No because the html i get doesnt have a comma between the end of the xp of 1 skill and the rank of the next one, only line feeds. so when i split it it merges the 2 in the same section.
     
  4. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    Hiscores lookup

    Why don't you split it by line feeds, and remove all commas? Seems like a plausible idea.
     
  5. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    how do i split by line feeds? lol sorry.
     
  6. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    Hiscores lookup

    Instead of using "," as a delimiter, try "\n".

    \n is a line feed.
     
  7. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    Didnt work, tried replacing all commas with line feeds and vice versa and neither worked as it went through searching for all occurances of "\n" and not line feeds.

    Is it because im using vb2005 and not vb6? (posted in the wrong forum and only just noticed sorry)

    Thanks for the help so far anyway.
     
  8. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    Hiscores lookup

    \n is always a line feed, regardless of language.
     
  9. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    oh ok. dunno what im doing wrong then :(
    can you help me abit more please?
    my code:
    Code:
        Private Sub btnLookUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLookUp.Click
            Dim name As String = txtUser.Text
            Dim src As String
    
            Dim net As New Net.WebClient()
            src = net.DownloadString("http://hiscore.runescape.com/index_lite.ws?player=" + name)
    
            src = src.Replace("\n", ",")
            skill = src.Split(",")
            'just to test output:
            Label1.Text = skill(1)
            Label2.Text = skill(2)
    
    
        End Sub
    
    
        Public Function GetPageHTML(ByVal URL As String) As String
            ' Retrieves the HTML from the specified URL
            Dim objWC As New System.Net.WebClient()
            Try
                Return New System.Text.UTF8Encoding().GetString(objWC.DownloadData(URL))
            Catch ex As Exception
                Return ""
    
            End Try
    
        End Function
    still merges xp of one skill with rank fo next.
     
  10. jdsfighter

    jdsfighter Forum Addict
    Visual Basic Programmers

    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    I just think I should point out... This is .Net and your in the Visual Basic 6 section. I don't think anyone cares anymore, but whatever.
     
  11. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    yeh i did point that out, only noticed half way through the topic.


    edit: i still care =\
     
  12. ajp121

    ajp121 Newcomer

    Joined:
    Jul 22, 2008
    Posts:
    10
    Referrals:
    0
    Sythe Gold:
    0
    Hiscores lookup

    ok Nvm, thansk for your help cp_, solved my problem by using 2008 instead of 2005 (it keeps the spaces in the string)
     
  13. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Hiscores lookup

    line feed is called vbLf, so try splitting by:
    Code:
    vbLf
    No quotation marks around it either.
     
< Msoft internet control is not showing websites | Installed vb 2005 - Confused. >


 
 
Adblock breaks this site