TMWA HTML Online list

Web discussions, including project website, forums, wiki, and others.
Post Reply
User avatar
Livio
Novice
Novice
Posts: 232
Joined: 26 Feb 2019, 20:08

TMWA HTML Online list

Post 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?
User avatar
Livio
Novice
Novice
Posts: 232
Joined: 26 Feb 2019, 20:08

Re: TMWA HTML Online list

Post 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]
User avatar
gumi
Administrator
Administrator
Posts: 781
Joined: 19 May 2014, 19:18

Re: TMWA HTML Online list

Post by gumi »

User avatar
Livio
Novice
Novice
Posts: 232
Joined: 26 Feb 2019, 20:08

Re: TMWA HTML Online list

Post 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:
Post Reply