hello,

I'm trying to convert the links in html pages to absolute links,
these pages can either be webpages or files on local harddisk (winXP).
Now I've struggling for a while, and this code works a lilttle:

      i = line.find ( 'href=' )
          if i < 0 :
              i = line.find ( ' src=' )
          if i >= 0 :
            ii = line.find ( '"', i+6 )
            file = line [ i+6 : ii ]
            #print urlparse.urljoin ( p, file )
            if file.find ( 'http:' ) < 0 :
                abspath = os.path.normpath ( os.path.join ( p, file ) )
                line = line.replace ( file, abspath )
            print line

but it only covers files on local disk and just 1 link per line,
so I guess it's a lot of trouble to catch all cases.
Isn't there a convenient function for (OS independent preferable) ?
Googled for it, but can't find it.

thanks,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to