#!/usr/bin/env python# -*- coding:utf-8 -*-# outils pour établir un index des membres JHimport re, urllibdef get_field(label, html): """retourne la valeur associée à la chaine <label> dans la page de profil téléchargée <html>""" pat = re.compile(r'''<td class="profilCase2">.*?%s.*?</td>.*?<td class="profilCase3">(.*?)</td>''' % label, re.S) field = re.search(pat, html) if field: return field.group(1) else: return Noneif __name__ == '__main__': for id in range(12905, 12910): html = urllib.urlopen("http://forum.judgehype.com/judgehype/profil-%s.htm" % id).read() for info in ('Pseudo', 'Sexe', 'messages', 'arrivée'): value = get_field(info, html) if value: print "%s : %s" % ( info, re.sub(r"&.*?;", "", value.strip()) ) print