annotate scrape-gm.py @ 16:eeee17d2072c default tip

Modify to search for a given server (IP:port). Player names are not returned in this case.
author Daniel O'Connor <darius@dons.net.au>
date Fri, 16 Oct 2009 23:41:42 +1030
parents 789cf10ce4c9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
1 #!/usr/bin/env python
ac32969d1bec Initial revision
darius
parents:
diff changeset
2
ac32969d1bec Initial revision
darius
parents:
diff changeset
3 ############################################################################
ac32969d1bec Initial revision
darius
parents:
diff changeset
4 # Screen scraper for game-monitor.com
ac32969d1bec Initial revision
darius
parents:
diff changeset
5 #
ac32969d1bec Initial revision
darius
parents:
diff changeset
6 # Prints out matched player names agreated by server
ac32969d1bec Initial revision
darius
parents:
diff changeset
7 #
ac32969d1bec Initial revision
darius
parents:
diff changeset
8 ############################################################################
ac32969d1bec Initial revision
darius
parents:
diff changeset
9 #
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
10 # Copyright (C) 2008 Daniel O'Connor. All rights reserved.
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
11 #
ac32969d1bec Initial revision
darius
parents:
diff changeset
12 # Redistribution and use in source and binary forms, with or without
ac32969d1bec Initial revision
darius
parents:
diff changeset
13 # modification, are permitted provided that the following conditions
ac32969d1bec Initial revision
darius
parents:
diff changeset
14 # are met:
ac32969d1bec Initial revision
darius
parents:
diff changeset
15 # 1. Redistributions of source code must retain the above copyright
ac32969d1bec Initial revision
darius
parents:
diff changeset
16 # notice, this list of conditions and the following disclaimer.
ac32969d1bec Initial revision
darius
parents:
diff changeset
17 # 2. Redistributions in binary form must reproduce the above copyright
ac32969d1bec Initial revision
darius
parents:
diff changeset
18 # notice, this list of conditions and the following disclaimer in the
ac32969d1bec Initial revision
darius
parents:
diff changeset
19 # documentation and/or other materials provided with the distribution.
ac32969d1bec Initial revision
darius
parents:
diff changeset
20 #
ac32969d1bec Initial revision
darius
parents:
diff changeset
21 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ac32969d1bec Initial revision
darius
parents:
diff changeset
22 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ac32969d1bec Initial revision
darius
parents:
diff changeset
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ac32969d1bec Initial revision
darius
parents:
diff changeset
24 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
ac32969d1bec Initial revision
darius
parents:
diff changeset
25 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ac32969d1bec Initial revision
darius
parents:
diff changeset
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
ac32969d1bec Initial revision
darius
parents:
diff changeset
27 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ac32969d1bec Initial revision
darius
parents:
diff changeset
28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
ac32969d1bec Initial revision
darius
parents:
diff changeset
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
ac32969d1bec Initial revision
darius
parents:
diff changeset
30 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ac32969d1bec Initial revision
darius
parents:
diff changeset
31 # SUCH DAMAGE.
ac32969d1bec Initial revision
darius
parents:
diff changeset
32 #
ac32969d1bec Initial revision
darius
parents:
diff changeset
33 ############################################################################
ac32969d1bec Initial revision
darius
parents:
diff changeset
34
ac32969d1bec Initial revision
darius
parents:
diff changeset
35 import re, time, datetime, urllib, sys, BeautifulSoup
ac32969d1bec Initial revision
darius
parents:
diff changeset
36
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
37 debug = False
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
38
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
39 class Server:
ac32969d1bec Initial revision
darius
parents:
diff changeset
40 alltags = re.compile('<[^>]*>')
ac32969d1bec Initial revision
darius
parents:
diff changeset
41 vwhttags = re.compile('<(br|hr)>')
ac32969d1bec Initial revision
darius
parents:
diff changeset
42 hwhttags = re.compile('\&nbsp;')
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
43 typetag = re.compile('<td><a href="/GameSearch/([^/]+)/.*</td>')
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
44
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
45 def __init__(self, description = "", ip = "", port = 0, mapname = "",
ac32969d1bec Initial revision
darius
parents:
diff changeset
46 updateage = 0, numplayers = 0, maxplayers = 0, players = []):
ac32969d1bec Initial revision
darius
parents:
diff changeset
47 self.description = description
ac32969d1bec Initial revision
darius
parents:
diff changeset
48 self.ip = ip
ac32969d1bec Initial revision
darius
parents:
diff changeset
49 self.port = port
ac32969d1bec Initial revision
darius
parents:
diff changeset
50 self.mapname = mapname
ac32969d1bec Initial revision
darius
parents:
diff changeset
51 self.updateage = int(updateage)
ac32969d1bec Initial revision
darius
parents:
diff changeset
52 self.players = []
ac32969d1bec Initial revision
darius
parents:
diff changeset
53 self.numplayers = numplayers
ac32969d1bec Initial revision
darius
parents:
diff changeset
54 self.maxplayers = maxplayers
ac32969d1bec Initial revision
darius
parents:
diff changeset
55
ac32969d1bec Initial revision
darius
parents:
diff changeset
56 def __init__(self, pcols, scols):
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
57 # For a server search..
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
58 # pcols[1] = Server description
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
59 # For a player search..
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
60 # pcols[1] = Player name
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
61 # pcols[2] = Server description
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
62 # scols[0] = Players in server / max players
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
63 # scols[1] = Server IP & port
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
64 # scols[2] = Map name
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
65 # scols[3] = Game type
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
66 # scols[8] = Update age
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
67 if debug:
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
68 print "pcols = " + str(pcols)
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
69 print "scols = " + str(scols)
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
70
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
71 self.pcountre = re.compile("([0-9]+)/([0-9]+)")
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
72 self.ipportre = re.compile("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+):([0-9]+)")
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
73 self.sdesc = re.compile(" +[0-9]+\. +(.*)")
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
74
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
75 if len(pcols) == 3:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
76 m = self.sdesc.match(pcols[2])
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
77 else:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
78 m = self.sdesc.match(pcols[1])
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
79
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
80 if (m == None):
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
81 raise SyntaxError
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
82 self.description = m.group(1)
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
83
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
84 m = self.ipportre.match(scols[1])
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
85 if (m == None):
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
86 raise SyntaxError
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
87
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
88 self.ip = m.group(1)
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
89 self.port = int(m.group(2))
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
90 self.gametype = scols[3]
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
91 self.mapname = scols[2]
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
92 self.updateage = scols[8]
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
93 m = self.pcountre.match(scols[0])
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
94 if (m == None):
ac32969d1bec Initial revision
darius
parents:
diff changeset
95 raise SyntaxError
ac32969d1bec Initial revision
darius
parents:
diff changeset
96
ac32969d1bec Initial revision
darius
parents:
diff changeset
97 self.numplayers = int(m.group(1))
ac32969d1bec Initial revision
darius
parents:
diff changeset
98 self.maxplayers = int(m.group(2))
ac32969d1bec Initial revision
darius
parents:
diff changeset
99 self.players = []
ac32969d1bec Initial revision
darius
parents:
diff changeset
100
ac32969d1bec Initial revision
darius
parents:
diff changeset
101 def __str__(self):
ac32969d1bec Initial revision
darius
parents:
diff changeset
102 plist = ""
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
103 if len(self.players) > 0:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
104 plist = ": "
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
105 for p in self.players:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
106 plist = plist + " " + str(p)
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
107 plist = plist + " "
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
108
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
109 return "%s: %s (%s:%d) | Map: %s | Players: %d/%d %s(%s old)" % \
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
110 (self.gametype, self.description, self.ip, self.port, self.mapname,
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
111 self.numplayers, self.maxplayers, plist,
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
112 self.updateage)
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
113
ac32969d1bec Initial revision
darius
parents:
diff changeset
114 def GetTuple(scols):
ac32969d1bec Initial revision
darius
parents:
diff changeset
115 return str(scols[2]) + ":" + str(scols[3])
ac32969d1bec Initial revision
darius
parents:
diff changeset
116 GetTuple = staticmethod(GetTuple)
ac32969d1bec Initial revision
darius
parents:
diff changeset
117
ac32969d1bec Initial revision
darius
parents:
diff changeset
118 def FixTags(s):
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
119 # Mangle game type
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
120 t = Server.typetag.match(s)
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
121 if t != None:
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
122 s = t.group(1)
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
123 s = re.sub(Server.vwhttags, '\n', s)
ac32969d1bec Initial revision
darius
parents:
diff changeset
124 s = re.sub(Server.hwhttags, '', s)
ac32969d1bec Initial revision
darius
parents:
diff changeset
125 s = str(BeautifulSoup.BeautifulStoneSoup( \
ac32969d1bec Initial revision
darius
parents:
diff changeset
126 s, convertEntities = BeautifulSoup.BeautifulStoneSoup.XML_ENTITIES))
ac32969d1bec Initial revision
darius
parents:
diff changeset
127 s = re.sub(Server.alltags, '', s)
ac32969d1bec Initial revision
darius
parents:
diff changeset
128 return(s)
ac32969d1bec Initial revision
darius
parents:
diff changeset
129 FixTags = staticmethod(FixTags)
ac32969d1bec Initial revision
darius
parents:
diff changeset
130
ac32969d1bec Initial revision
darius
parents:
diff changeset
131 def Scrape(handle):
ac32969d1bec Initial revision
darius
parents:
diff changeset
132 s = BeautifulSoup.BeautifulSoup(handle)
ac32969d1bec Initial revision
darius
parents:
diff changeset
133
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
134 playertbl = s.find("table", "results")
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
135 if (playertbl == None):
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
136 if True:
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
137 print "Unable to find results"
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
138 return None
ac32969d1bec Initial revision
darius
parents:
diff changeset
139
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
140 servertbl = playertbl.findNext("table")
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
141
ac32969d1bec Initial revision
darius
parents:
diff changeset
142 playerrows = playertbl.findAll("tr")
ac32969d1bec Initial revision
darius
parents:
diff changeset
143 serverrows = servertbl.findAll("tr")
ac32969d1bec Initial revision
darius
parents:
diff changeset
144
ac32969d1bec Initial revision
darius
parents:
diff changeset
145 if (len(playerrows) != len(serverrows)):
ac32969d1bec Initial revision
darius
parents:
diff changeset
146 print "Internal error 41223"
ac32969d1bec Initial revision
darius
parents:
diff changeset
147 return
ac32969d1bec Initial revision
darius
parents:
diff changeset
148
ac32969d1bec Initial revision
darius
parents:
diff changeset
149 servers = {}
ac32969d1bec Initial revision
darius
parents:
diff changeset
150 for i in range(len(playerrows[1:])):
ac32969d1bec Initial revision
darius
parents:
diff changeset
151 pcols = playerrows[i].findAll('td')
ac32969d1bec Initial revision
darius
parents:
diff changeset
152 scols = serverrows[i].findAll('td')
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
153 if len(pcols) != 3 and len(pcols) != 2:
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
154 if debug:
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
155 print "pcols has length %d, expected 2 or 3" % len(pcols)
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
156 continue
ac32969d1bec Initial revision
darius
parents:
diff changeset
157
ac32969d1bec Initial revision
darius
parents:
diff changeset
158 pcols = map(lambda c : Server.FixTags(str(c)), pcols)
ac32969d1bec Initial revision
darius
parents:
diff changeset
159 scols = map(lambda c : Server.FixTags(str(c)), scols)
ac32969d1bec Initial revision
darius
parents:
diff changeset
160
ac32969d1bec Initial revision
darius
parents:
diff changeset
161 stuple = Server.GetTuple(scols)
ac32969d1bec Initial revision
darius
parents:
diff changeset
162
ac32969d1bec Initial revision
darius
parents:
diff changeset
163 if (stuple not in servers):
ac32969d1bec Initial revision
darius
parents:
diff changeset
164 s = Server(pcols, scols)
ac32969d1bec Initial revision
darius
parents:
diff changeset
165 servers[stuple] = s
ac32969d1bec Initial revision
darius
parents:
diff changeset
166
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
167 # Only add players if it's a player query
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
168 if len(pcols) == 3:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
169 servers[stuple].addplayer(pcols[1])
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
170
ac32969d1bec Initial revision
darius
parents:
diff changeset
171 return servers
ac32969d1bec Initial revision
darius
parents:
diff changeset
172 Scrape = staticmethod(Scrape)
ac32969d1bec Initial revision
darius
parents:
diff changeset
173
ac32969d1bec Initial revision
darius
parents:
diff changeset
174 def addplayer(self, pname):
ac32969d1bec Initial revision
darius
parents:
diff changeset
175 self.players.append(pname)
ac32969d1bec Initial revision
darius
parents:
diff changeset
176
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
177
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
178 isipadrre = re.compile('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+')
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
179
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
180 if True:
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
181 maxhits = 10
ac32969d1bec Initial revision
darius
parents:
diff changeset
182 if (len(sys.argv) < 2):
ac32969d1bec Initial revision
darius
parents:
diff changeset
183 print "Bad usage"
ac32969d1bec Initial revision
darius
parents:
diff changeset
184 print sys.argv[0] + "search_string"
ac32969d1bec Initial revision
darius
parents:
diff changeset
185 sys.exit(1)
ac32969d1bec Initial revision
darius
parents:
diff changeset
186
ac32969d1bec Initial revision
darius
parents:
diff changeset
187 try:
ac32969d1bec Initial revision
darius
parents:
diff changeset
188 #f = open("gm.html")
16
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
189 if isipadrre.match(sys.argv[1]) == None:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
190 f = urllib.urlopen("http://www.game-monitor.com/search.php?location=AU&search=" + urllib.quote(sys.argv[1]) + "&type=player&location=AU")
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
191 else:
eeee17d2072c Modify to search for a given server (IP:port).
Daniel O'Connor <darius@dons.net.au>
parents: 15
diff changeset
192 f = urllib.urlopen("http://www.game-monitor.com/search.php?location=AU&search=" + urllib.quote(sys.argv[1]))
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
193 except IOError, e:
ac32969d1bec Initial revision
darius
parents:
diff changeset
194 print "Unable to fetch page - " + str(e)
ac32969d1bec Initial revision
darius
parents:
diff changeset
195 sys.exit(0)
ac32969d1bec Initial revision
darius
parents:
diff changeset
196
ac32969d1bec Initial revision
darius
parents:
diff changeset
197 servers = Server.Scrape(f)
ac32969d1bec Initial revision
darius
parents:
diff changeset
198 del f
6
5058c2695109 Properly report if we can't parse the results.
darius
parents: 5
diff changeset
199 if (servers == None):
5058c2695109 Properly report if we can't parse the results.
darius
parents: 5
diff changeset
200 print "No results available, please check manually"
5058c2695109 Properly report if we can't parse the results.
darius
parents: 5
diff changeset
201 elif (len(servers) == 0):
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
202 print "No players found"
ac32969d1bec Initial revision
darius
parents:
diff changeset
203 else:
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
204 tmp = []
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
205 for i in servers:
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
206 tmp.append(servers[i])
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
207 tmp.sort()
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
208 i = 0
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
209 for s in tmp:
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
210 i = i + 1
15
789cf10ce4c9 Update for new format (for sure)
darius@Inchoate
parents: 6
diff changeset
211 print s
1
ac32969d1bec Initial revision
darius
parents:
diff changeset
212 if (i >= maxhits):
ac32969d1bec Initial revision
darius
parents:
diff changeset
213 print "*** Stopping after " + str(maxhits) + " hits"
ac32969d1bec Initial revision
darius
parents:
diff changeset
214 break