Scrapy, a fast high-level web crawling & scraping framework for Python.
Fixed bug in open_in_browser() function with Python 2.5 (closes #145).
Pablo Hoffmanc5cd8b9d3d16
diff --git a/scrapy/utils/response.py b/scrapy/utils/response.pyindex a1a83d2ac..6ed6f43a3 100644--- a/scrapy/utils/response.py+++ b/scrapy/utils/response.py@@ -3,12 +3,11 @@ This module provides some useful functions for working withscrapy.http.Response objects"""-from __future__ import with_statement-+import osimport reimport weakrefimport webbrowser-from tempfile import NamedTemporaryFile+import tempfilefrom twisted.web import httpfrom twisted.web.http import RESPONSES@@ -104,6 +103,7 @@ def open_in_browser(response):body = response.bodyif '<base' not in body:body = body.replace('<head>', '<head><base href="%s">' % response.url)- with NamedTemporaryFile(suffix='.html', delete=False) as f:- f.write(body)- webbrowser.open("file://%s" % f.name)+ fd, fname = tempfile.mkstemp('.html')+ os.write(fd, body)+ os.close(fd)+ webbrowser.open("file://%s" % fname)