diff --git a/addons/0.pageDownloader.py b/addons/0.pageDownloader.py index 3a097cf..083c475 100644 --- a/addons/0.pageDownloader.py +++ b/addons/0.pageDownloader.py @@ -16,16 +16,19 @@ def downloadPage(url,headers = False): class rdrh(urllib.request.HTTPRedirectHandler): def redirect_request(self,req,fp,code,msg,hdrs,newurl): response["url"] = newurl - return urllib.request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, hdrs, newurl) + try: + return urllib.request.HTTPRedirectHandler.redirect_request(self, req, fp, code, msg, hdrs, newurl) + except urllib.error.HTTPError as e: + return e opener = urllib.request.build_opener(rdrh) outHeaders = [] for header in headers: outHeaders.append((header,headers[header])) opener.addheaders = outHeaders - requestHandler = opener.open(url) try: + requestHandler = opener.open(url) response["headers"] = requestHandler.getheaders() response["body"] = requestHandler.read() except urllib.error.HTTPError as e: