I have the following code that returns the title of webpage
def get_title(url):
page = urllib2.urlopen(url)
p = lxml.html.parse(page)
return p.find(".//title").text
1) Is this the most efficient method of finding a pages title (even after redirects)
2) How can I account for all the various exceptions that may occur (i.e. HTTPErrors, URLError, etc). I dont want to just use except Exception as e
to catchall. I want to have specific exceptions