Results 1 to 1 of 1
  1. Default GMS rank lookup script


    Hello!

    Just posting this up in case it would be useful to someone other than me.

    Usually, I don't want to take the time to load Nexon's web page just to check basic info about someone. So, I came up with this. It's a PowerShell script that parses the GMS rank listing for any characters you feed it. Unlisted or invalid names will show all dashes. If you want to grab the character's avatar, the -avatar option will download each one. Avatars will be stored as GIF files with each character's name.

    I've tested on Windows 7, but it should work on any system with PowerShell 2.0 or higher.

    Usage:
    Code:
    Get-Rank.ps1 [-avatar] name1 name2 ...
    Script:
    Code:
    # Get-Rank.ps1
    #
    # Given a list of names, pass them through Nexon's rank listing to show
    # job and level, or state that they aren't listed.
    
    param(
    	[switch]$avatar = $false # Dump avatar to file if true
    )
    
    $nxweb = new-object net.webclient
    
    foreach ( $name in $args ) {
    	$rankpage = $nxweb.DownloadString("http://maplestory.nexon.net/Rankings/OverallRanking.aspx?type=overall&s=l&pageIndex=1&key=" + $name + "&search=true&searchtype=name")
    	# Find script block where the character is in the ranking table
    	$regex = "(?si)<script type=`"text/javascript`">\s+if \(\'$name\' == \'$name\'(.*?)</tr>"
    	$found = $rankpage -imatch $regex
    
    	if ( $found ) {
    		$chardata = $matches[0]
    		
    		# Now we have a chunk of HTML that we can parse for character stats.
    		# We will build a hash table and make it into an object, so this script's
    		#  output can be piped to Format-Table or Convertto-HTML or whatever.
    		
    		$a = $chardata -imatch "(?si)<td class=`"level-move`">\s+<div style=`"display:block`">\s+(\d{1,3})"
    		$level = $matches[1]
    		
    		$a = $chardata -imatch "title=`"([\w\s]+)`""
    		$job = $matches[1]
    		
    		$a = $chardata -imatch "</script>\s+<td class=`"ac`">(\d{1,})"
    		$overallrank = $matches[1]
    		
    		if ( $avatar ) {
    			$a = $chardata -imatch "(http://msavatar1.nexon.net/Character/\w+\.gif)"
    			$avatarurl = $matches[1]
    			if ( $avatarurl ) {
    				$nxweb.DownloadFile( $avatarurl, "$pwd\$name.gif" )
    			}
    		}
    		
    		$a = $chardata -imatch "(?si)<a class=`"world\s([\w\s]+)`""
    		$world = (Get-Culture).textinfo.totitlecase( $matches[1] )
    
    		$CharProperties = @{
    			Name = $name
    			Level = $level
    			Job = $job
    			World = $world
    			Overall = $overallrank
    		}
    	}
    	else {
    		$CharProperties = @{
    			Name = $name
    			Level = "-"
    			Job = "-"
    			World = "-"
    			Overall = "-"
    		}
    	}
    	
    	new-object PSobject -property $CharProperties
    }
    Example:
    Code:
    PS C:\Users\JoeJimBob\Scripts> .\Get-Rank.ps1 Chevette OneTooMini doesntexist | format-table
    
    Name                    Level                   Overall                 World                   Job
    ----                    -----                   -------                 -----                   ---
    Chevette                127                     349689                  Khaini                  Magician
    OneTooMini              55                      2360499                 Khaini                  Jett
    doesntexist             -                       -                       -                       -
    Changelog


    Enjoy! Any comments or feedback are welcome!
    Last edited by rassilon; 2012-07-25 at 09:24 PM. Reason: Updated script, added changelog

  2.  

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •