python html

Walter Dörwald walter at livinglogic.de
Fri Aug 19 09:27:53 EDT 2005


Steve Young wrote:

> Hi, I am looking for something where I can go through
> a html page and make change the url's for all the
> links, images, href's, etc... easily. If anyone knows
> of something, please let me know. Thanks.

You might try XIST (http://www.livinglogic.de/Python/xist)

Code might look like this:

from ll.xist import xsc, parsers

node = parsers.parseURL("http://www.python.org/", tidy=True)

for link in node//xsc.URLAttr:
    link[:] = unicode(link).replace(
       "http://www.python.org/",
       "http://www.perl.org/"
    )
print node.asBytes()

Bye,
    Walter Dörwald



More information about the Python-list mailing list