Parsing multiple string form website into listview.

Posts 1–10 of 10 · Page 1 of 1
Parsing multiple string form website into listview.
So guys i need small help here.
i got already this working but its parsing only one string, but in my website the strings are duplicated.
i mean by i got on website like this.

[gq_hostname] => Something random
[gq_hostname] => Something random 2

so in the listview its shows me only the first parsing, not all strings.

so here is the source code:
Code:
            Dim code As String
            Using client As New WebClient

                code = client.DownloadString("http://127.0.0.1/servers/examples/list.php")




                Dim gametype As String = Split(Split(code, "[gq_type] => ")(1), "[hostname]")(0)
                Dim servername As String = Split(Split(code, "[gq_hostname] => ")(1), "[gq_mapname]")(0)
                Dim map As String = Split(Split(code, "[gq_mapname] => ")(1), "[gq_maxplayers]")(0)
                Dim players As String = Split(Split(code, "[gq_numplayers] => ")(1), "[gq_online]")(0)
                Dim maxplayers As String = Split(Split(code, "[gq_maxplayers] => ")(1), "[gq_mod]")(0)
                Dim ip As String = Split(Split(code, "[gq_address] => ")(1), "[gq_dedicated]")(0)
                Dim port As String = Split(Split(code, "[gq_port] => ")(1), "[gq_protocol]")(0)






            
                Dim item = ListView1.Items.Add(Trim(gametype))
                For cnt As Integer = 1 To ListView1.Columns.Count
                    item.SubItems.Add(Trim(servername))
                Next



                item.SubItems(2).Text = Trim(map)
                item.SubItems(3).Text = Trim(players) + "/" + Trim(maxplayers)

            End Using
        Catch ex As Exception
        End Try
look like:


but its should be like this





please if someone can help me i will glad.
thanks.
can u post the entire raw output from the webpage. ? (minus anything 'sensitive' of course)

It's because of where you call Split(Split(...)) , you're only including 1 server name...you need to parse the string differently.
If you post the raw output, I'll give it a shot. Regex could probably be used.
Code:
Array
(
    [server1] => Array
        (
            [bot_quota] => 0
            [coop] => 0
            [daf_version] => Version 4b of SourceOP.com DoS Attack Fix Plugin
            [deathmatch] => 1
            [decalfrequency] => 10
            [dedicated] => d
            [game_descr] => Counter-Strike: Source
            [game_dir] => cstrike
            [gq_address] => 82.166.147.8
            [gq_dedicated] => d
            [gq_gametype] => 
            [gq_hostname] => Gamers-Israel.****** | Server 3 | Public
            [gq_mapname] => de_dust2
            [gq_maxplayers] => 32
            [gq_mod] => cstrike
            [gq_numplayers] => 11
            [gq_online] => 1
            [gq_password] => 0
            [gq_port] => 27017
            [gq_protocol] => source
            [gq_transport] => udp
            [gq_type] => css
            [hostname] => Gamers-Israel.****** | Server 3 | Public
            [map] => de_dust2
            [max_players] => 32
            [metamod_version] => 1.10.0-devV
            [mp_allowNPCs] => 1
            [mp_autocrosshair] => 1
            [mp_autoteambalance] => 1
            [mp_c4timer] => 45
            [mp_disable_respawn_times] => 0
            [mp_fadetoblack] => 0
            [mp_falldamage] => 0
            [mp_flashlight] => 1
            [mp_footsteps] => 1
            [mp_forceautoteam] => 0
            [mp_forcerespawn] => 1
            [mp_fraglimit] => 0
            [mp_freezetime] => 5
            [mp_friendlyfire] => 0
            [mp_holiday_nogifts] => 0
            [mp_hostagepenalty] => 13
            [mp_limitteams] => 2
            [mp_match_end_at_timelimit] => 0
            [mp_maxrounds] => 0
            [mp_respawnwavetime] => 10.0
            [mp_roundtime] => 3
            [mp_scrambleteams_auto] => 1
            [mp_scrambleteams_auto_windifference] => 2
            [mp_stalemate_enable] => 0
            [mp_stalemate_meleeonly] => 0
            [mp_startmoney] => 800
            [mp_teamlist] => hgrunt;scientist
            [mp_teamplay] => 0
            [mp_teams_unbalance_limit] => 1
            [mp_timelimit] => 0
            [mp_tournament] => 0
            [mp_weaponstay] => 0
            [mp_winlimit] => 0
            [nextlevel] => 
            [num_bots] => 0
            [num_players] => 11
            [num_rules] => 105
            [os] => w
            [password] => 0
            [players] => Array
                (
                    [0] => Array
                        (
                            [id] => 0
                            [name] => Laho
                            [score] => 26
                            [time] => 1596.5609130859
                            [gq_name] => Laho
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 26
                            [gq_ping] => 
                        )

                    [1] => Array
                        (
                            [id] => 0
                            [name] => Green Poni Horse [On WeedS]
                            [score] => 9
                            [time] => 1575.4558105469
                            [gq_name] => Green Poni Horse [On WeedS]
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 9
                            [gq_ping] => 
                        )

                    [2] => Array
                        (
                            [id] => 0
                            [name] => ™๖ Ship☺p☻ ●̮̮̃•
                            [score] => 17
                            [time] => 1470.4711914062
                            [gq_name] => ™๖ Ship☺p☻ ●̮̮̃•
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 17
                            [gq_ping] => 
                        )

                    [3] => Array
                        (
                            [id] => 0
                            [name] => wicked sick
                            [score] => 21
                            [time] => 1262.3654785156
                            [gq_name] => wicked sick
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 21
                            [gq_ping] => 
                        )

                    [4] => Array
                        (
                            [id] => 0
                            [name] => Batson
                            [score] => 8
                            [time] => 1030.7032470703
                            [gq_name] => Batson
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 8
                            [gq_ping] => 
                        )

                    [5] => Array
                        (
                            [id] => 0
                            [name] => xatSTART[G]
                            [score] => 17
                            [time] => 834.56195068359
                            [gq_name] => xatSTART[G]
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 17
                            [gq_ping] => 
                        )

                    [6] => Array
                        (
                            [id] => 0
                            [name] => ][_, ([]) ][_,
                            [score] => 0
                            [time] => 506.49133300781
                            [gq_name] => ][_, ([]) ][_,
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [7] => Array
                        (
                            [id] => 0
                            [name] => Stranger`
                            [score] => 0
                            [time] => 322.05017089844
                            [gq_name] => Stranger`
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [8] => Array
                        (
                            [id] => 0
                            [name] => BiNgO
                            [score] => 0
                            [time] => 283.47061157227
                            [gq_name] => BiNgO
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [9] => Array
                        (
                            [id] => 0
                            [name] => Ezra
                            [score] => 0
                            [time] => 122.74493408203
                            [gq_name] => Ezra
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [10] => Array
                        (
                            [id] => 0
                            [name] => F£vèr
                            [score] => 2
                            [time] => 89.969635009766
                            [gq_name] => F£vèr
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 2
                            [gq_ping] => 
                        )

                )

            [protocol] => 17
            [r_AirboatViewDampenDamp] => 1.0
            [r_AirboatViewDampenFreq] => 7.0
            [r_AirboatViewZHeight] => 0.0
            [r_JeepViewDampenDamp] => 1.0
            [r_JeepViewDampenFreq] => 7.0
            [r_JeepViewZHeight] => 10.0
            [r_VehicleViewDampen] => 1
            [rankme_version] => 2.8.3
            [rtler_version] => 1.0.5
            [sb_version] => 1.4.10
            [scp_version] => 1.1.5
            [secure] => 1
            [sm_adv_version] => 0.16
            [sm_allchat_version] => 1.1.1
            [sm_block_flashlight_sound_version] => 1.0
            [sm_downloader_version] => 1.4
            [sm_information_version] => 3.5
            [sm_mostactive_version] => v1.2
            [sm_nextmap] => 
            [sm_resetscore_version] => 2.5.1
            [sm_spraymanager_version] => 1.1
            [sm_teambets_version] => 2.6
            [smac_version] => 0.8.4.0
            [sourcecomms_version] => 0.9.9
            [sourcemod_version] => 1.5.0-dev+3842
            [steamappid] => 240
            [steamtools_version] => 0.8.3
            [stripper_version] => 1.2.2
            [sv_accelerate] => 5
            [sv_airaccelerate] => 1337
            [sv_allowminmodels] => 1
            [sv_alltalk] => 0
            [sv_bounce] => 0
            [sv_cheats] => 0
            [sv_competitive_minspec] => 0
            [sv_contact] => 
            [sv_enableboost] => 1
            [sv_enablebunnyhopping] => 1
            [sv_footsteps] => 1
            [sv_friction] => 4
            [sv_gravity] => 800
            [sv_maxspeed] => 320
            [sv_maxusrcmdprocessticks] => 24
            [sv_noclipaccelerate] => 5
            [sv_noclipspeed] => 5
            [sv_nostats] => 0
            [sv_password] => 0
            [sv_pausable] => 0
            [sv_rollangle] => 0
            [sv_rollspeed] => 200
            [sv_specaccelerate] => 5
            [sv_specnoclip] => 1
            [sv_specspeed] => 3
            [sv_steamgroup] => 
            [sv_stepsize] => 18
            [sv_stopspeed] => 75
            [sv_tags] => bunnyhopping
            [sv_voiceenable] => 1
            [sv_wateraccelerate] => 10
            [sv_waterfriction] => 1
            [teams] => Array
                (
                )

            [tf_arena_max_streak] => 3
            [tf_arena_preround_time] => 10
            [tf_arena_round_time] => 0
            [tf_arena_use_queue] => 1
            [tv_enable] => 1
            [tv_password] => 0
            [tv_relaypassword] => 0
            [version] => 49
        )

    [server2] => Array
        (
            [ban_disconnected_ver] => 1.04
            [bot_quota] => 0
            [coop] => 0
            [daf_version] => Version 4b of SourceOP.com DoS Attack Fix Plugin
            [deathmatch] => 1
            [deathrun_manager_version] => 1.1
            [decalfrequency] => 10
            [dedicated] => d
            [game_descr] => Counter-Strike: Source
            [game_dir] => cstrike
            [goto_version] => 1.2
            [gq_address] => 82.166.147.8
            [gq_dedicated] => d
            [gq_gametype] => 
            [gq_hostname] => Gamers-Israel.****** | Server 2 | Fun | Store | Timer
            [gq_mapname] => mg_kegs_course_v3_fixed3
            [gq_maxplayers] => 32
            [gq_mod] => cstrike
            [gq_numplayers] => 3
            [gq_online] => 1
            [gq_password] => 0
            [gq_port] => 27016
            [gq_protocol] => source
            [gq_transport] => udp
            [gq_type] => css
            [hostname] => Gamers-Israel.****** | Server 2 | Fun | Store | Timer
            [macrodox_version] => 1.9
            [map] => mg_kegs_course_v3_fixed3
            [max_players] => 32
            [metamod_version] => 1.9.3-devV
            [mp_allowNPCs] => 1
            [mp_autocrosshair] => 1
            [mp_autoteambalance] => 0
            [mp_c4timer] => 35
            [mp_disable_respawn_times] => 0
            [mp_fadetoblack] => 0
            [mp_falldamage] => 0
            [mp_flashlight] => 1
            [mp_footsteps] => 1
            [mp_forceautoteam] => 0
            [mp_forcerespawn] => 1
            [mp_fraglimit] => 0
            [mp_freezetime] => 0
            [mp_friendlyfire] => 0
            [mp_holiday_nogifts] => 0
            [mp_hostagepenalty] => 13
            [mp_limitteams] => 0
            [mp_match_end_at_timelimit] => 0
            [mp_maxrounds] => 0
            [mp_respawnwavetime] => 10.0
            [mp_roundtime] => 8
            [mp_scrambleteams_auto] => 1
            [mp_scrambleteams_auto_windifference] => 2
            [mp_stalemate_enable] => 0
            [mp_stalemate_meleeonly] => 0
            [mp_startmoney] => 16000
            [mp_teamlist] => hgrunt;scientist
            [mp_teamplay] => 0
            [mp_teams_unbalance_limit] => 1
            [mp_timelimit] => 0
            [mp_tournament] => 0
            [mp_weaponstay] => 0
            [mp_winlimit] => 0
            [nextlevel] => 
            [num_bots] => 0
            [num_players] => 3
            [num_rules] => 120
            [os] => w
            [password] => 0
            [physicsattackercheck_version] => 1.0.0.1
            [players] => Array
                (
                    [0] => Array
                        (
                            [id] => 0
                            [name] => Well Done
                            [score] => -1
                            [time] => 4144.0966796875
                            [gq_name] => Well Done
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => -1
                            [gq_ping] => 
                        )

                    [1] => Array
                        (
                            [id] => 0
                            [name] => SizEx
                            [score] => -1
                            [time] => 1456.8475341797
                            [gq_name] => SizEx
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => -1
                            [gq_ping] => 
                        )

                    [2] => Array
                        (
                            [id] => 0
                            [name] => Spot ` (kone dvarim me ha shop)
                            [score] => -5
                            [time] => 1083.662109375
                            [gq_name] => Spot ` (kone dvarim me ha shop)
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => -5
                            [gq_ping] => 
                        )

                )

            [protocol] => 17
            [r_AirboatViewDampenDamp] => 1.0
            [r_AirboatViewDampenFreq] => 7.0
            [r_AirboatViewZHeight] => 0.0
            [r_JeepViewDampenDamp] => 1.0
            [r_JeepViewDampenFreq] => 7.0
            [r_JeepViewZHeight] => 10.0
            [r_VehicleViewDampen] => 1
            [rtler_version] => 1.0.5
            [sb_version] => 1.4.10
            [scp_version] => 1.1.5
            [secure] => 1
            [sedirector_version] => 2.0
            [sm_adv_version] => 0.16
            [sm_anti_team_flash_version] => 1.2.3
            [sm_blockradio_version] => 2.0.2
            [sm_grenadesmokecolor_version] => 1.2
            [sm_hitnrun_enabled] => 1
            [sm_information_version] => 3.5
            [sm_knifetop_debug] => 0
            [sm_knifetop_enabled] => 1
            [sm_knifetop_version] => 1.2.4
            [sm_mapsimprover_version] => 1.3.3.7
            [sm_napalmlagfix_version] => 1.0.2
            [sm_nextmap] => mg_mario_kart_v1_fix
            [sm_parachute_version] => 2.5
            [sm_resize_version] => 1.4.0
            [sm_show_damage_version] => 1.0.7
            [sm_spraymanager_version] => 1.1
            [sm_thirdperson_version] => 1.4
            [sm_weaponnoblock_version] => 1.0.1
            [smac_version] => 0.8.4.0
            [sourcecomms_version] => 0.9.9
            [sourcemod_version] => 1.5.0-dev+3871
            [steamappid] => 240
            [steamtools_version] => 0.8.3
            [store_version] => 1.1-alpha
            [stripper_version] => 1.2.2
            [sv_accelerate] => 5
            [sv_airaccelerate] => 9999999999
            [sv_allowminmodels] => 1
            [sv_alltalk] => 1
            [sv_bounce] => 0
            [sv_cheats] => 0
            [sv_competitive_minspec] => 0
            [sv_contact] => 
            [sv_enableboost] => 1
            [sv_enablebunnyhopping] => 1
            [sv_footsteps] => 1
            [sv_friction] => 4
            [sv_gravity] => 800
            [sv_maxspeed] => 320
            [sv_maxusrcmdprocessticks] => 24
            [sv_noclipaccelerate] => 5
            [sv_noclipspeed] => 5
            [sv_nostats] => 0
            [sv_password] => 0
            [sv_pausable] => 0
            [sv_rollangle] => 0
            [sv_rollspeed] => 200
            [sv_specaccelerate] => 5
            [sv_specnoclip] => 1
            [sv_specspeed] => 3
            [sv_steamgroup] => 
            [sv_stepsize] => 18
            [sv_stopspeed] => 75
            [sv_tags] => alltalk,bunnyhopping,startmoney
            [sv_voiceenable] => 1
            [sv_wateraccelerate] => 10
            [sv_waterfriction] => 1
            [teams] => Array
                (
                )

            [tf_arena_max_streak] => 3
            [tf_arena_preround_time] => 10
            [tf_arena_round_time] => 0
            [tf_arena_use_queue] => 1
            [timer_version] => 1.0.7
            [tv_enable] => 0
            [tv_password] => 0
            [tv_relaypassword] => 0
            [version] => 49
        )

    [server3] => Array
        (
            [bot_quota] => 0
            [coop] => 0
            [daf_version] => Version 4b of SourceOP.com DoS Attack Fix Plugin
            [deathmatch] => 1
            [decalfrequency] => 10
            [dedicated] => d
            [game_descr] => Counter-Strike: Source
            [game_dir] => cstrike
            [gq_address] => 82.166.147.8
            [gq_dedicated] => d
            [gq_gametype] => 
            [gq_hostname] => Gamers-Israel.****** | Server 3 | Public
            [gq_mapname] => de_dust2
            [gq_maxplayers] => 32
            [gq_mod] => cstrike
            [gq_numplayers] => 11
            [gq_online] => 1
            [gq_password] => 0
            [gq_port] => 27017
            [gq_protocol] => source
            [gq_transport] => udp
            [gq_type] => css
            [hostname] => Gamers-Israel.****** | Server 3 | Public
            [map] => de_dust2
            [max_players] => 32
            [metamod_version] => 1.10.0-devV
            [mp_allowNPCs] => 1
            [mp_autocrosshair] => 1
            [mp_autoteambalance] => 1
            [mp_c4timer] => 45
            [mp_disable_respawn_times] => 0
            [mp_fadetoblack] => 0
            [mp_falldamage] => 0
            [mp_flashlight] => 1
            [mp_footsteps] => 1
            [mp_forceautoteam] => 0
            [mp_forcerespawn] => 1
            [mp_fraglimit] => 0
            [mp_freezetime] => 5
            [mp_friendlyfire] => 0
            [mp_holiday_nogifts] => 0
            [mp_hostagepenalty] => 13
            [mp_limitteams] => 2
            [mp_match_end_at_timelimit] => 0
            [mp_maxrounds] => 0
            [mp_respawnwavetime] => 10.0
            [mp_roundtime] => 3
            [mp_scrambleteams_auto] => 1
            [mp_scrambleteams_auto_windifference] => 2
            [mp_stalemate_enable] => 0
            [mp_stalemate_meleeonly] => 0
            [mp_startmoney] => 800
            [mp_teamlist] => hgrunt;scientist
            [mp_teamplay] => 0
            [mp_teams_unbalance_limit] => 1
            [mp_timelimit] => 0
            [mp_tournament] => 0
            [mp_weaponstay] => 0
            [mp_winlimit] => 0
            [nextlevel] => 
            [num_bots] => 0
            [num_players] => 11
            [num_rules] => 105
            [os] => w
            [password] => 0
            [players] => Array
                (
                    [0] => Array
                        (
                            [id] => 0
                            [name] => Laho
                            [score] => 26
                            [time] => 1596.5911865234
                            [gq_name] => Laho
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 26
                            [gq_ping] => 
                        )

                    [1] => Array
                        (
                            [id] => 0
                            [name] => Green Poni Horse [On WeedS]
                            [score] => 9
                            [time] => 1575.4860839844
                            [gq_name] => Green Poni Horse [On WeedS]
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 9
                            [gq_ping] => 
                        )

                    [2] => Array
                        (
                            [id] => 0
                            [name] => ™๖ Ship☺p☻ ●̮̮̃•
                            [score] => 17
                            [time] => 1470.5014648438
                            [gq_name] => ™๖ Ship☺p☻ ●̮̮̃•
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 17
                            [gq_ping] => 
                        )

                    [3] => Array
                        (
                            [id] => 0
                            [name] => wicked sick
                            [score] => 21
                            [time] => 1262.3957519531
                            [gq_name] => wicked sick
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 21
                            [gq_ping] => 
                        )

                    [4] => Array
                        (
                            [id] => 0
                            [name] => Batson
                            [score] => 8
                            [time] => 1030.7333984375
                            [gq_name] => Batson
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 8
                            [gq_ping] => 
                        )

                    [5] => Array
                        (
                            [id] => 0
                            [name] => xatSTART[G]
                            [score] => 17
                            [time] => 834.59222412109
                            [gq_name] => xatSTART[G]
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 17
                            [gq_ping] => 
                        )

                    [6] => Array
                        (
                            [id] => 0
                            [name] => ][_, ([]) ][_,
                            [score] => 0
                            [time] => 506.52157592773
                            [gq_name] => ][_, ([]) ][_,
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [7] => Array
                        (
                            [id] => 0
                            [name] => Stranger`
                            [score] => 0
                            [time] => 322.08041381836
                            [gq_name] => Stranger`
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [8] => Array
                        (
                            [id] => 0
                            [name] => BiNgO
                            [score] => 0
                            [time] => 283.50085449219
                            [gq_name] => BiNgO
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [9] => Array
                        (
                            [id] => 0
                            [name] => Ezra
                            [score] => 0
                            [time] => 122.77517700195
                            [gq_name] => Ezra
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 0
                            [gq_ping] => 
                        )

                    [10] => Array
                        (
                            [id] => 0
                            [name] => F£vèr
                            [score] => 2
                            [time] => 89.999885559082
                            [gq_name] => F£vèr
                            [gq_kills] => 
                            [gq_deaths] => 
                            [gq_score] => 2
                            [gq_ping] => 
                        )

                )

            [protocol] => 17
            [r_AirboatViewDampenDamp] => 1.0
            [r_AirboatViewDampenFreq] => 7.0
            [r_AirboatViewZHeight] => 0.0
            [r_JeepViewDampenDamp] => 1.0
            [r_JeepViewDampenFreq] => 7.0
            [r_JeepViewZHeight] => 10.0
            [r_VehicleViewDampen] => 1
            [rankme_version] => 2.8.3
            [rtler_version] => 1.0.5
            [sb_version] => 1.4.10
            [scp_version] => 1.1.5
            [secure] => 1
            [sm_adv_version] => 0.16
            [sm_allchat_version] => 1.1.1
            [sm_block_flashlight_sound_version] => 1.0
            [sm_downloader_version] => 1.4
            [sm_information_version] => 3.5
            [sm_mostactive_version] => v1.2
            [sm_nextmap] => 
            [sm_resetscore_version] => 2.5.1
            [sm_spraymanager_version] => 1.1
            [sm_teambets_version] => 2.6
            [smac_version] => 0.8.4.0
            [sourcecomms_version] => 0.9.9
            [sourcemod_version] => 1.5.0-dev+3842
            [steamappid] => 240
            [steamtools_version] => 0.8.3
            [stripper_version] => 1.2.2
            [sv_accelerate] => 5
            [sv_airaccelerate] => 1337
            [sv_allowminmodels] => 1
            [sv_alltalk] => 0
            [sv_bounce] => 0
            [sv_cheats] => 0
            [sv_competitive_minspec] => 0
            [sv_contact] => 
            [sv_enableboost] => 1
            [sv_enablebunnyhopping] => 1
            [sv_footsteps] => 1
            [sv_friction] => 4
            [sv_gravity] => 800
            [sv_maxspeed] => 320
            [sv_maxusrcmdprocessticks] => 24
            [sv_noclipaccelerate] => 5
            [sv_noclipspeed] => 5
            [sv_nostats] => 0
            [sv_password] => 0
            [sv_pausable] => 0
            [sv_rollangle] => 0
            [sv_rollspeed] => 200
            [sv_specaccelerate] => 5
            [sv_specnoclip] => 1
            [sv_specspeed] => 3
            [sv_steamgroup] => 
            [sv_stepsize] => 18
            [sv_stopspeed] => 75
            [sv_tags] => bunnyhopping
            [sv_voiceenable] => 1
            [sv_wateraccelerate] => 10
            [sv_waterfriction] => 1
            [teams] => Array
                (
                )

            [tf_arena_max_streak] => 3
            [tf_arena_preround_time] => 10
            [tf_arena_round_time] => 0
            [tf_arena_use_queue] => 1
            [tv_enable] => 1
            [tv_password] => 0
            [tv_relaypassword] => 0
            [version] => 49
        )

)
here its is. this how the webpage displays itself.
Well, I tried : )




 
Code

Code:
    '// A Handy structure for passing the information around

    Public Structure GameServer
        Public GameDescription As String
        Public HostName As String
        Public MapName As String
        Public MaxPlayers As Int32
        Public CurrentPlayers As Int32
    End Structure
Code:
 Public Function ParseServerData(ByRef webPageContents As String) As GameServer()
        Dim _rtns As New List(Of GameServer)
        Dim _aGameServer As GameServer

        Dim _serverChunks() As String = Split(webPageContents, "[server") '' (0) is junk, 1= serv1, 2 = serv2, etc.
        Dim _serverChunkLines() As String '' all lines of 1 chunk

        For servCount As Int32 = 1 To _serverChunks.Length - 1
            ''Loop over each chunk, 1-n.
            _serverChunkLines = Split(_serverChunks(servCount), Environment.NewLine) '' Split into individual lines
            For Each ss As String In _serverChunkLines
                ss = ss.Trim() '' Remove spacing from each line

                If ss.StartsWith("[game_descr]") Then
                    _aGameServer.GameDescription = Split(ss, "=> ")(1)
                ElseIf ss.StartsWith("[gq_hostname]") Then
                    _aGameServer.HostName = Split(ss, "=> ")(1) ''  hostname | Server # | Public  --> could be split again to find only hostname
                ElseIf ss.StartsWith("[gq_mapname]") Then
                    _aGameServer.MapName = Split(ss, "=> ")(1)
                ElseIf ss.StartsWith("[gq_numplayers]") Then
                    _aGameServer.CurrentPlayers = CInt(Split(ss, "=> ")(1))
                ElseIf ss.StartsWith("[gq_maxplayers]") Then
                    _aGameServer.MaxPlayers = CInt(Split(ss, "=> ")(1))
                End If
            Next
            _rtns.Add(_aGameServer)
        Next

        Return _rtns.ToArray
    End Function
--------------------------And this is how I tested it -----------------------------

1) I saved your post of raw output to .txt file
Code:
 Const _filePath As String = "C:\Users\Buckau\Desktop\servInfo.txt"
        Dim _fileContents As String = System****.File.ReadAllText(_filePath)
        Dim _serverInfos() As GameServer = ParseServerData(_fileContents)
        For Each host As GameServer In _serverInfos
            MsgBox("Server Information: " & Environment.NewLine _
                 & "Host: " & host.HostName & Environment.NewLine _
                 & "Map: " & host.MapName & Environment.NewLine _
                 & "Description: " & host.GameDescription & Environment.NewLine _
                 & "Players: " & host.CurrentPlayers & " / " & host.MaxPlayers)
        Next


Hope that helps. If you run into bugs, let me know.

edit: the line " Dim _serverChunks() As String = Split(webPageContents, "[server") " is extremely dangerous...if a random string like Username or server_descr contains "[server", this code will fail, miserably.

edit: also, _aGameServer should be reset to default values at the end of each loop, else it might hold old data.

Apparently usernames aren't ascii --> are [ ]'s brackets allowed to be in a username? Could a username begin with [server ?

edit: "[6] => Array
(
[id] => 0
[name] => ][_, ([]) ][_,
[score] => 0
[time] => 506.52157592773
[gq_name] => ][_, ([]) ][_,
[gq_kills] =>
[gq_deaths] =>
[gq_score] => 0
[gq_ping] =>
)
}

:| Nevermind, my solution won't work!! If a name contains "[server", this code sill surely fail/show incorrect data.

^^Same thing with your code: If a username contains any of the [***] hardcoded strings, it will cause errors.


My basic idea is:

1) split file into "chunks" : each "chunk" == 1 server --apparently harder than I thought : p
2) parse info from each chunk


But maybe it gives you ideas, I'll work on it more later.
ty for tried but if you can post me a source code at pastebin.com its will be more clear to read.
thanks, anyone else?
I think this should work, I tested it and the results were correct.
(I hope you understand why I'm storing the information in a Structure? ..just for convenience)


[VB.NET] Parse server output - Pastebin.com
 
The Code

Code:
    Public Function ParseServerData(ByRef webPageContent As String) As GameServer()
        Dim _rtns As New List(Of GameServer)
        Dim _aGameServer As New GameServer
        Dim _contentLines() As String = webPageContent.Split(CChar(Environment.NewLine))
        Dim _tmpLine As String = ""

        For xx As Int32 = 0 To _contentLines.Length - 1
            _tmpLine = _contentLines(xx).Trim()
            If _tmpLine.StartsWith("[server") Then
                'this is the start of a server info region
                Do Until _tmpLine.StartsWith("[version]") '' [version] is currently the last item in the list.
                    xx += 1
                    If xx = _contentLines.Length Then
                        ''array out of bounds, [version] never found, invalid server output!
                        Throw New Exception("ParseServerData:: [version] not found at end of server info. Invalid server data. Contact game server administrator.")
                        ''I hate throwing exceptions - this shouldn't happen unless the server gives bad output.
                    End If
                    _tmpLine = _contentLines(xx).Trim()
                    If _tmpLine.StartsWith("[hostname]") Then
                        _aGameServer.HostName = Split(_tmpLine, "=> ")(1)
                    ElseIf _tmpLine.StartsWith("[gq_mapname]") Then
                        _aGameServer.MapName = Split(_tmpLine, "=> ")(1)
                    ElseIf _tmpLine.StartsWith("[gq_numplayers]") Then
                        _aGameServer.CurrentPlayers = CInt(Split(_tmpLine, "=> ")(1))
                    ElseIf _tmpLine.StartsWith("[gq_maxplayers]") Then
                        _aGameServer.MaxPlayers = CInt(Split(_tmpLine, "=> ")(1))
                    ElseIf _tmpLine.StartsWith("[game_descr]") Then
                        _aGameServer.GameDescription = Split(_tmpLine, "=> ")(1)
                    ElseIf _tmpLine.StartsWith("[gq_address]") Then
                        _aGameServer.HostAddress = Split(_tmpLine, "=> ")(1)
                    ElseIf _tmpLine.StartsWith("[gq_port]") Then
                        _aGameServer.HostPort = CInt(Split(_tmpLine, "=> ")(1))
                    End If
                Loop
                _rtns.Add(_aGameServer)
                _aGameServer.Reset() '' reset values to defaults - clear old data.
            End If
        Next

        Return _rtns.ToArray
    End Function
Code:
    Public Structure GameServer
        Public GameDescription As String
        Public HostName As String
        Public MapName As String
        Public MaxPlayers As Int32
        Public CurrentPlayers As Int32
        Public HostAddress As String
        Public HostPort As Int32

        Public Sub Reset()
            GameDescription = ""
            HostName = ""
            MapName = ""
            MaxPlayers = 0
            CurrentPlayers = 0
            HostAddress = ""
            HostPort = 0
        End Sub
    End Structure


-----------------------------------------------------
I'm copy-pasting your original code, and modifying it to use my function/structure.

Code:
 Dim code As String
 Dim _servers() As GameServer '' An array of 'server' objects. Each has info like .Address, .Port, .NumPlayer , .MapName etc.

            Using client As New WebClient

                code = client.DownloadString("http://127.0.0.1/servers/examples/list.php")

                _servers = ParseServerData(code)
                ''After this point, each item in the "_servers" array is filled with valid data.

                For Each _host As GameServer In _servers
                '' Add each server info to the list view, or
                MsgBox(_host.HostName & ":" & _host.HostPort & Environment.newLine _
                          & "Map: " & _host.MapName & Environment.NewLine _
                          & "Players: " & _host.CurrentPlayers.ToString() & "/" &  _host.MaxPlayers.ToString())
                ''TODO: Erase the MsgBox() and add the info to a list view.
                Next

            End Using
^^I think this solves the issue about 'User defined values' (name, server descrip., etc) containing any of the hard-coded strings.

edit: made 1 small last change, still functionally equivalent.
http://pastebin.com/221yPu04

Test and let me know? Copy-Paste the Structure + Function, test, and see if works. ? At first you should just get a msgbox for each server, then change the code to add them to list view : )
yea i think so, but its still not working, its not showing me any msgbox, i don't get any errors.
if you got some free time to try to help me with that contact me with skype: shahar-bos
thanks.
:/ worked for me, unless the server output changed drastically.

Added you on skype.
Hah, I wasn't thinking about the new-line character used, anyway,


Public Function ParseServerData(ByRef webPageContent As String) As GameServer()

Dim _contentLines() As String = webPageContent.Split(Chr(10))
...

Tested w/ OP, works correctly.

edit: Also found out when the servers are "down", they leave a few fields blank which was causing Split(***)(1) to throw an exception (because it only had item 0: the split never happend, there was no right side of the string).

new function: http://pastebin.com/urwwaP46
 
code

Public Shared Function ParseServerData(ByRef webPageContent As String) As GameHost()
Dim _rtnHosts As New List(Of GameHost)
Dim _aGameHost As New GameHost
Dim _contentLines() As String = webPageContent.Split(Chr(10)) ''Split webPageContent into individual lines

Dim _tmpLine As String = "" ''Stores temporary copy of .trimmed version of each individual line.
Dim _leftBracketCount As Int32 = 0 ''Used to find end of each reagion, ie. closing bracket.

For xx As Int32 = 0 To _contentLines.Length - 1
_tmpLine = _contentLines(xx).Trim()
If _tmpLine.StartsWith("[server") Then ''this is the start of a server info region
xx += 2 ''skip the next line, it's the opening bracket ( --> _leftCurlyCount should now be 1.
_leftBracketCount = 1
Do
If xx = _contentLines.Length Then
Throw New Exception("ParseServerData:: Index out of bound. Invalid server output. Please contact game administrators.") '' Missing closing ) ?
End If
_tmpLine = _contentLines(xx).Trim()
If _tmpLine = "(" Then
_leftBracketCount += 1
ElseIf _tmpLine = ")" Then
_leftBracketCount -= 1
ElseIf _tmpLine.StartsWith("[gq_hostname]") Then
If _tmpLine = "[gq_hostname] =>" Then
''no host name
_aGameHost.HostName = "None"
Else
_aGameHost.HostName = Split(_tmpLine, "=> ")(1)
End If
ElseIf _tmpLine.StartsWith("[gq_mapname]") Then
If _tmpLine = "[gq_mapname] =>" Then
''no map name
_aGameHost.MapName = "None"
Else
_aGameHost.MapName = Split(_tmpLine, "=> ")(1)
End If
ElseIf _tmpLine.StartsWith("[gq_numplayers]") Then
If _tmpLine = "[gq_numplayers] =>" Then
''no number of players
_aGameHost.CurrentPlayers = 0
Else
_aGameHost.CurrentPlayers = CInt(Split(_tmpLine, "=> ")(1))
End If
ElseIf _tmpLine.StartsWith("[gq_maxplayers]") Then
If _tmpLine = "[gq_maxplayers] =>" Then
''no max players
_aGameHost.MaxPlayers = 0
Else
_aGameHost.MaxPlayers = CInt(Split(_tmpLine, "=> ")(1))
End If
ElseIf _tmpLine.StartsWith("[game_descr]") Then
If _tmpLine = "[game_descr] =>" Then
''no description
_aGameHost.GameDescription = "None"
Else
_aGameHost.GameDescription = Split(_tmpLine, "=> ")(1)
End If

ElseIf _tmpLine.StartsWith("[gq_address]") Then
If _tmpLine = "[gq_address] =>" Then
''no address
_aGameHost.HostAddress = "0.0.0.0" '' or 'None', for consistency. ?
Else
_aGameHost.HostAddress = Split(_tmpLine, "=> ")(1)
End If
ElseIf _tmpLine.StartsWith("[gq_port]") Then
If _tmpLine = "[gq_port] =>" Then
''no port
_aGameHost.HostPort = 0
Else
_aGameHost.HostPort = CInt(Split(_tmpLine, "=> ")(1))
End If
End If
xx += 1
Loop While _leftBracketCount > 0
_rtnHosts.Add(_aGameHost)
_aGameHost.Reset() '' reset values to defaults - clear old data.
End If
Next

Return _rtnHosts.ToArray
End Function
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us