Hi, python experts.
<console trace>
chaouche@CAY:~/TEST$ python nettoyageHTML.py
chaouche@CAY:~/TEST$
</console trace>
This is the nettoyageHTML.py python script
<code>
from HTMLParser import HTMLParser
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 ?
Y.Chaouche 3 1718
ychaouche wrote:
Hi, python experts.
<console trace>
chaouche@CAY:~/TEST$ python nettoyageHTML.py
chaouche@CAY:~/TEST$
</console trace>
This is the nettoyageHTML.py python script
<code>
from HTMLParser import HTMLParser
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
On 29 jan, 16:45, "Diez B. Roggisch" <d...@nospam.web.dewrote:
ychaouche wrote:
Hi, python experts.
<console trace>
chaouche@CAY:~/TEST$ python nettoyageHTML.py
chaouche@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
ychaouche wrote:
class ParseurHTML(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
def start_body(self,attrs):
print "this is my body"
def start_tag(self, name, attrs):
if name == 'body':
print "this is my body" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Adonis |
last post by:
When parsing my html files, I use handle_pi to capture some embedded python
code, but I have noticed that in the embedded python code if it contains
html, HTMLParser will parse it as well, and thus...
|
by: Sean Cody |
last post by:
I'm trying to take a webpage that has a nxn table of entries (bus times) and
convert it to a 2D array (list of lists). Initially this was simple but I
need to be able to access whole 'columns' of...
|
by: Matthew Wilson |
last post by:
I want to parse an html file and extract my router's IP address. I
wrote this code and I have python 2.3 installed:
#! /usr/bin/env python
import HTMLParser
class...
|
by: Kevin T. Ryan |
last post by:
Hi all -
I'm somewhat new to python (about 1 year), and I'm trying to write a program
that opens a file like object w/ urllib.urlopen, and then parse the data by
passing it to a class that...
|
by: Lawrence D'Oliveiro |
last post by:
I've been using HTMLParser to scrape Web sites. The trouble with this
is, there's a lot of malformed HTML out there. Real browsers have to be
written to cope gracefully with this, but HTMLParser...
|
by: Kenneth McDonald |
last post by:
I'm writing a program that will parse HTML and (mostly) convert it to
MediaWiki format. The two Python modules I'm aware of to do this are
HTMLParser and htmllib. However, I'm currently...
|
by: Just Another Victim of the Ambient Morality |
last post by:
HTMLParser is behaving in, what I find to be, strange ways and I would
like to better understand what it is doing and why.
First, it doesn't appear to translate HTML escape characters. I don't...
|
by: jonbutler88 |
last post by:
Just writing a simple website spider in python, keep getting these
errors, not sure what to do. The problem seems to be in the feed()
function of htmlparser.
Traceback (most recent call last):...
|
by: globalrev |
last post by:
tried all kinds of combos to get this to work.
http://docs.python.org/lib/module-HTMLParser.html
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |