HTMLParser's start_tag method never called ?

ychaouche yacinechaouche at gmail.com
Tue Feb 6 03:52:04 EST 2007


On 29 jan, 16:45, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
> ychaouche wrote:
> > Hi, python experts.
>
> > <console trace>
> > chaouche at CAY:~/TEST$ python nettoyageHTML.py
> > chaouche at CAY:~/TEST$
> > </console trace>
>
> > This is the nettoyageHTML.py python script
>
> > <code>
> > fromHTMLParserimportHTMLParser
>
> > class ParseurHTML(HTMLParser):
> >     def __init__(self):
> >        HTMLParser.__init__(self)
>
> >     def start_body(self,attrs):
> >         print "this is my body"
>
> > p = ParseurHTML()
> > p.feed(open("/home/chaouche/TEST/AJAX/testXMLRPC.html","r").read())
> > </code>
>
> > this is the testXMLRPC.html html file :
>
> > <html>
> > <head>
> > <script type="text/javascript" language="javascript"
> > src="ClientXMLRPC.js">
> > </script>
>
> > <script type="text/javascript" language="javascript" >
>
> >     if (typeof netscape != 'undefined' && typeof netscape.security !=
> > 'undefined') {
>
> > netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRea
> > d');
> >     }
>
> > var chiffre = 0;
> > handler = function (self){
> >     if (self.xmlhttp.readyState == 4) {
> >         reponse = self.xmlhttp.responseText;
> > //dump(reponse); permet d'acceder au dom si ce qu'on a recu est une
> > forme de xml.
> > document.getElementById("txt").innerHTML=reponse;
> >     }
> > }
>
> > function recupDonnees(){
> >     chiffre+=1;
> >     client = new ClientXMLRPC();
> >     client.setUrl("http://10.75.49.100:8081/bonjour/sayHi?
> > chiffre="+chiffre);
> >     client.executer();
> >     client.handlerEvenement = handler;
> > }
> > recupDonnees();
>
> > </script>
> > </head>
> > <body>
>
> > <span id="txt">NON</span>
> > </body>
> > </html>
>
> > The script should output "this is my body", but nothing is printed.
> > Anyone ?
>
> You need a p.close() after the feed I guess.
>
> Diez

I tried p.close() and nothing happens.
Y.Chaouche




More information about the Python-list mailing list