473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question: processing HTML, re-write default processing action of many tags

I know you could use the
def start_a
.....

def end_a
.....

to process the <a href=...> anchor </a> tags, but is there a
default method for processing ALL tags? If I just want change
some parts of the hyperlink and want to keep other parts of the HTML
could I just print them out? There should be such a method.
Can't find it...

Thank you.
Jul 18 '05 #1
2 1170
Hubert Hung-Hsien Chang <hu****@cs.nyu.edu> wrote:
I know you could use the
def start_a
....

def end_a
....

to process the <a href=...> anchor </a> tags, but is there a
default method for processing ALL tags? If I just want change
some parts of the hyperlink and want to keep other parts of the HTML
could I just print them out? There should be such a method.
Can't find it...


You could subclass HTMLParser.HTMLParser and override handle_starttag
and handle_endtag (also, if needed, handle_charref, handle_entityref,
and last but not least handle_data -- that's assuming that while you
only talk about processing _tags_ you may in fact also want to process
references and text nodes... possibly handle_comment, too, btw).
Alex
Jul 18 '05 #2
hu****@cs.nyu.edu (Hubert Hung-Hsien Chang) wrote in message news:<98**************************@posting.google. com>...
I know you could use the
def start_a
....

def end_a
....

to process the <a href=...> anchor </a> tags, but is there a
default method for processing ALL tags? If I just want change
some parts of the hyperlink and want to keep other parts of the HTML
could I just print them out? There should be such a method.
Can't find it...

Thank you.


If you are modifying the contents of tags I've written a simple HTML
parser class called Scraper that does this. Unlike the HTMLParser in
the standard library it doesn't choke so much on badly formed HTML....

It's part of approx.py my cgiproxy....
http://www.voidspace.org.uk/atlantib....html#cgiproxy

HTH

Regards,

Fuzzy
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jan Plastenjak | last post by:
This question is about html. I have this: <frameset rows="90%,10%" frameborder="NO" border="0" framespacing="0" cols="1"> <frame name="topFrame" noresize src="c:\bpp.xml"> <frame name="bottom" ...
4
by: | last post by:
I do have icq on my computer, and I am interested it for another reason. But I don't have time at the moment to look into it. My question is regard to HTML (and either asp or xml in HTML mode). ...
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
4
by: Nigel Molesworth | last post by:
I've Googled, but can't find what I need, perhaps I asking the wrong question! I want a "FAQ" page on a web site, I hate those pages that scroll you to the answer so and I figured that a good...
3
by: Patrick | last post by:
Hi experts, I am trying to help a guy fix up an incomplete site, other coder quit. I have a question about how the site narrows the main page in a frame view. The page is formatted to have large...
2
by: Jukka K. Korpela | last post by:
This question is fairly theoretical (even for me), but it started to puzzle me: According to the SGML declaration for HTML 4.01, at http://www.w3.org/TR/REC-html40/sgml/sgmldecl.html#h-20.1 the...
6
by: alexrussell101 | last post by:
For anyone who can't be bothered to read my code and examples, scroll to the bottom, the question's there. Thanks. I'm using php and regular expressions to convert bbcode style things to html....
4
by: vincent90152900 | last post by:
How to remove Security Question and Security Answer from membership provider? Following is my codes. Please tell me how to remove Question and Answer from membership provider. Thank you for...
3
by: maximisedk | last post by:
I need to create a HTML table for a number of users. Each user will have a unique HTML table in regard to number of columns, as the user can choose to append columns to his HTML table. The way I...
2
by: Vohaul | last post by:
Hi there, I'm new to this site, but have been doing webpages with flash, html, css for a few years. I'm a convert from graphic designer to web Anyway, I have a client site that i designed a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.