string encoding regex problem

Philipp Kraus philipp.kraus at flashpixx.de
Fri Aug 15 20:27:57 EDT 2014


Hello,

I have defined a function with:

def URLReader(url) :
    try :
        f = urllib2.urlopen(url)
        data = f.read()
        f.close()
    except Exception, e :
        raise MyError.StopError(e)
    return data

which get the HTML source code from an URL. I use this to get a part of 
a HTML document without any HTML parsing, so I call (I would like to 
get the download link of the boost library):

found = re.search( "<a 
href=\"/projects/boost/files/latest/download\?source=files\" 
title=\"/boost/(.*)", 
Utilities.URLReader("http://sourceforge.net/projects/boost/files/boost/") 
)
if found == None :
	raise MyError.StopError("Boost Download URL not found")

But found is always None, so I cannot get the correct match. I didn't 
find the error in my code.

Thanks for help

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140816/de3ece77/attachment.html>


More information about the Python-list mailing list