Page 1 of 1

TMWA HTML Online list

Posted: 12 Dec 2019, 13:45
by Livio
I have some problems in replacing manachat's old algorithm to gather online list in game. Actually I've spotted a code syntax error when a Game Master logs in resolving it into a unnecessary b tag enclosure.
Nothing game-compromising but I have problems understanding python regexp and failed to list names that contains spaces.

Is there another source when online players list can be gathered?

Re: TMWA HTML Online list

Posted: 12 Dec 2019, 14:21
by Livio
Sorry, nevermind...

Solved with that code of shame:

Code: Select all

#!/usr/bin/env python
from HTMLParser import HTMLParser
import urllib2
import re

class MLStripper(HTMLParser):
    def __init__(self):
        self.reset()
        self.fed = []
    def handle_data(self, d):
        self.fed.append(d)
    def get_data(self):
        return ''.join(self.fed)

def strip_tags(html):
    s = MLStripper()
    s.feed(html)
    return s.get_data()

#Filter html tags and excape codes
data=re.sub(r'<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});\r\n\t', '', strip_tags(urllib2.urlopen('https://server.themanaworld.org/online.html').read())).splitlines()

newdata = []
for x in data:
	newdata.append(x.strip())

print filter(None, newdata)[3:-1]

Re: TMWA HTML Online list

Posted: 12 Dec 2019, 16:19
by gumi

Re: TMWA HTML Online list

Posted: 12 Dec 2019, 16:47
by Livio
NOOOOOOOOOO!!!!!!!!!
I've wasted an entire day to fix that... :cry:

Thanks for that info Gumi!
If I only had known before... :alt-4: