"""
Simple, strightforward robot; guaranteed to has problems with timeouts :)
- Written by BroytMann, Mar 2000 - Aug 2002. Copyright (C) 2000-2002 PhiloSoft Design
+ Written by BroytMann, Mar 2000 - Sep 2007. Copyright (C) 2000-2007 PhiloSoft Design
"""
url_host, url_path = urllib.splithost(url_rest)
url_path, url_tag = urllib.splittag(url_path)
+ if bookmark.charset: urllib._urlopener.addheader('Accept-Charset', bookmark.charset)
fname, headers = urllib.urlretrieve("%s://%s%s" % (url_type, url_host, url_path), self.tempfname)
+ if bookmark.charset: del urllib._urlopener.addheaders[-1]
size = 0
last_modified = None
if self.log: self.log(" final title : %s" % bookmark.real_title)
if parser.refresh:
refresh = parser.refresh
- try:
- timeout = int(refresh.split(';')[0])
- except (IndexError, ValueError):
- timeout = "ERROR"
try:
url = refresh.split('=', 1)[1]
except IndexError:
url = "self"
- raise RedirectException("html", "%s (%d sec)" % (url, timeout))
+ try:
+ timeout = int(refresh.split(';')[0])
+ except (IndexError, ValueError):
+ timeout = None
+ if timeout is None:
+ raise RedirectException("html", "Bad redirect to %s (%s)" % (url, refresh))
+ else:
+ raise RedirectException("html", "%s (%d sec)" % (url, timeout))
except KeyError:
pass
def finish_check_url(self, bookmark):
# Calculate these attributes even in case of an error
if os.path.exists(self.tempfname):
- size = str(os.stat(self.tempfname).st_size)
+ size = str(os.path.getsize(self.tempfname))
if size[-1] == 'L':
size = size[:-1]
bookmark.size = size