From 5c9d104a30bde82cdc49b49e972ff4db4e0a7b9d Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Thu, 28 Feb 2013 04:19:34 +0100 Subject: dtube: better error handling when target not found --- dtube/dtube.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dtube') diff --git a/dtube/dtube.py b/dtube/dtube.py index 7261ef5..7cc7a5f 100755 --- a/dtube/dtube.py +++ b/dtube/dtube.py @@ -104,14 +104,14 @@ class He: self.html = requests.get(url, headers=He.url_headers) if self.verbose: print self.html.status_code if not self.html.ok: - if self.html.status_code == 404: - raise Exception("Target not found") self.html.raise_for_status() self.tree = etree.HTML(self.html.content) if not getattr(self.html, 'from_cache', False): time.sleep(random.random() * 3) # Forced to be kind if self.verbose and self.html.from_cache: print "Response from cache" + if re.search(r'ERROR: .* Not Found', self.tree.xpath('//title')[0].text): + raise Exception("Target not found") class HeAS(He): url_prefix = '/AS' -- cgit v1.2.3-59-g8ed1b