A small tool can get warband and wfas server list(2015/12/18 Update!)

正在查看此主题的用户

DoDoCat

Squire
Hi, I write a small tool that can get warband and wfas server list. Here are some screenshots:
b8fa0dd3d35f8a9e.png


cbc40cde87fd821a.png


Gui Version(wxpython):
3585de8db8817a25.png


Gui Version(New Update)
jb2t7o.png


Github:
https://github.com/NetworkOffice/M-B-Server-Get

Google Drive:sad:Lastest Gui Version)
https://drive.google.com/file/d/0B563M0AHYgpYYXBTX01PX0hZYlE/view?usp=sharing
 
Awesome stuff! I've been meaning to do this as well. I made a few changes to make it more pythonic:

插入代码块:
import urllib
import urllib2
import re

def run():
    url="http://warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas"
    headers={
        "GET":"warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas",
        "Host":"warbandmain.taleworlds.com",
        "User-Agent":"Mozilla/4.0",
        }
    
    try:
        req=urllib2.Request(url)
    except urllib2.URLError, e:
        print 'bailing on %s ' % (url)
        return None
    
    for key in headers:
        req.add_header(key,headers[key])
        
    html = urllib2.urlopen(req).read()
    #print output
    adressList = re.findall("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:\d{1,5}[^|]|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}[^|]",html)
    for ipadress in adressList:
        print ipadress

if __name__ == "__main__":
    run()

If I save this script as "wb.py" I can get the adresses by doing:

import wb
wb.run()


It's a good habbit to have the if main stuff in files where you have functions and even more so in files which contain classes(which this should be as I'm keeping my state variables inside a function for being lazy.)

Whenever you are doing something with networking always do a try - except. This is because one day the website url might change and therefor your program won't work. Catching it with an except will take care of this and make it more future proof.

Again, awesome job and good on you for choosing Python!!
 
Windle 说:
Awesome stuff! I've been meaning to do this as well. I made a few changes to make it more pythonic:

插入代码块:
import urllib
import urllib2
import re

def run():
    url="http://warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas"
    headers={
        "GET":"warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas",
        "Host":"warbandmain.taleworlds.com",
        "User-Agent":"Mozilla/4.0",
        }
    
    try:
        req=urllib2.Request(url)
    except urllib2.URLError, e:
        print 'bailing on %s ' % (url)
        return None
    
    for key in headers:
        req.add_header(key,headers[key])
        
    html = urllib2.urlopen(req).read()
    #print output
    adressList = re.findall("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:\d{1,5}[^|]|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}[^|]",html)
    for ipadress in adressList:
        print ipadress

if __name__ == "__main__":
    run()

If I save this script as "wb.py" I can get the adresses by doing:

import wb
wb.run()


It's a good habbit to have the if main stuff in files where you have functions and even more so in files which contain classes(which this should be as I'm keeping my state variables inside a function for being lazy.)

Whenever you are doing something with networking always do a try - except. This is because one day the website url might change and therefor your program won't work. Catching it with an except will take care of this and make it more future proof.

Again, awesome job and good on you for choosing Python!!
CamelCase in Python volcom? umad
 
Windle 说:
Awesome stuff! I've been meaning to do this as well. I made a few changes to make it more pythonic:

插入代码块:
import urllib
import urllib2
import re

def run():
    url="http://warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas"
    headers={
        "GET":"warbandmain.taleworlds.com/handlerservers.ashx?type=list&gametype=wfas",
        "Host":"warbandmain.taleworlds.com",
        "User-Agent":"Mozilla/4.0",
        }
    
    try:
        req=urllib2.Request(url)
    except urllib2.URLError, e:
        print 'bailing on %s ' % (url)
        return None
    
    for key in headers:
        req.add_header(key,headers[key])
        
    html = urllib2.urlopen(req).read()
    #print output
    adressList = re.findall("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:\d{1,5}[^|]|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}[^|]",html)
    for ipadress in adressList:
        print ipadress

if __name__ == "__main__":
    run()

If I save this script as "wb.py" I can get the adresses by doing:

import wb
wb.run()


It's a good habbit to have the if main stuff in files where you have functions and even more so in files which contain classes(which this should be as I'm keeping my state variables inside a function for being lazy.)

Whenever you are doing something with networking always do a try - except. This is because one day the website url might change and therefor your program won't work. Catching it with an except will take care of this and make it more future proof.

Again, awesome job and good on you for choosing Python!!
Nice
 
后退
顶部 底部