Subdomain Posts
Python | 498 days ago
Python | 499 days ago
Python | 499 days ago
Python | 499 days ago
Python | 499 days ago
Python | 538 days ago
Python | 538 days ago
Python | 538 days ago
Python | 584 days ago
Python | 584 days ago
Recent Posts
None | 0 sec ago
JavaScript | 10 sec ago
None | 18 sec ago
None | 30 sec ago
None | 1 min ago
None | 1 min ago
None | 2 min ago
None | 2 min ago
None | 2 min ago
None | 3 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By kahrn on the 28th of Sep 2008 05:35:19 PM Download | Raw | Embed | Report
  1. """
  2. bf2xml.py
  3.    Ricky Hewitt <kahrny@gmail.com>
  4.    Part of the xbot irc bot.
  5.    
  6.    This script is able to display BF2 server information by
  7.    obtaining and parsing an XML file.
  8.    Relies on game-monitor.com (for now).
  9.    
  10.    TODO: Add Current Map (limited due to limitations of XML feed)
  11. """
  12.  
  13. import urllib
  14. from xml.dom import minidom
  15.  
  16. def get_server_info(HOST="74.53.113.68:16567"):
  17.     """Retrieve information for a given IP address (e.g. 127.0.0.1:16567).
  18.       Output is in the form of a list."""
  19.     HOST_URL = 'http://module.game-monitor.com/%s/data/server.xml' % (HOST)
  20.    
  21.     dom = minidom.parse(urllib.urlopen(HOST_URL))
  22.     for node in dom.getElementsByTagName('ip'):
  23.         server_ip = node.firstChild.data
  24.     for node in dom.getElementsByTagName('port'):
  25.         server_port = node.firstChild.data
  26.        
  27.     for node in dom.getElementsByTagName('name'):
  28.         server_name = node.firstChild.data
  29.     for node in dom.getElementsByTagName('query_time'):
  30.         server_ping = node.firstChild.data
  31.        
  32.     for node in dom.getElementsByTagName('player'):
  33.         server_players = node.firstChild.data
  34.     for node in dom.getElementsByTagName('maxplayer'):
  35.         server_mplayers = node.firstChild.data
  36.        
  37.     for node in dom.getElementsByTagName('link'):
  38.         server_link = node.firstChild.data
  39.        
  40.     server_info = []
  41.     server_info.append(str(server_ip) + ":" + str(server_port) + " : " + str(server_name) + " : " + str(server_players) + "/" + str(server_mplayers) + " : " + str(server_ping))
  42.     #server_info.append(str(server_link))
  43.    
  44.     return server_info
  45.  
  46. if __name__=="__main__":
  47.     serverinfo = get_server_info()
  48.     for i in serverinfo:
  49.         print i
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: