Here are the examples of the python api scrapy.utils.response.open_in_browser taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
Project: scrapy Source File: test_utils_response.py
def test_open_in_browser(self):
url = "http:///www.example.com/some/page.html"
body = b"<html> <head> <title>test page</title> </head> <body>test body</body> </html>"
def browser_open(burl):
path = urlparse(burl).path
if not os.path.exists(path):
path = burl.replace('file://', '')
with open(path, "rb") as f:
bbody = f.read()
self.assertIn(b'<base href="' + to_bytes(url) + b'">', bbody)
return True
response = HtmlResponse(url, body=body)
assert open_in_browser(response, _openfunc=browser_open), \
"Browser not called"
resp = Response(url, body=body)
self.assertRaises(TypeError, open_in_browser, resp, debug=True)
0
Example 2
def _print_response(self, response, opts):
open_in_browser(response)