5.5 KiB
Splash¶
render.json Return a json-encoded dictionary with information about javascript-rendered webpage. It can include HTML, PNG and other information, based on arguments passed.
Arguments:
Same as render.jpeg plus the following ones:
html : integer : optional Whether to include HTML in output. Possible values are 1 (include) and 0 (exclude). Default is 0. png : integer : optional Whether to include PNG in output. Possible values are 1 (include) and 0 (exclude). Default is 0. jpeg : integer : optional Whether to include JPEG in output. Possible values are 1 (include) and 0 (exclude). Default is 0. iframes : integer : optional Whether to include information about child frames in output. Possible values are 1 (include) and 0 (exclude). Default is 0. script : integer : optional Whether to include the result of the executed javascript final statement in output (see Executing custom Javascript code within page context). Possible values are 1 (include) and 0 (exclude). Default is 0. console : integer : optional Whether to include the executed javascript console messages in output. Possible values are 1 (include) and 0 (exclude). Default is 0. history : integer : optional Whether to include the history of requests/responses for webpage main frame. Possible values are 1 (include) and 0 (exclude). Default is 0.
Use it to get HTTP status codes and headers. Only information about “main” requests/responses is returned (i.e. information about related resources like images and AJAX queries is not returned). To get information about all requests and responses use ‘har’ argument.
har : integer : optional Whether to include HAR in output. Possible values are 1 (include) and 0 (exclude). Default is 0. If this option is ON the result will contain the same data as render.har provides under ‘har’ key.
By default, request and response contents are not included. To enable each, use ‘request_body’ and ‘response_body’ options respectively.
request_body : int : optional Possible values are 1 and 0. When request_body=1, request content is included in HAR records. Default is request_body=0. This option has no effect when both ‘har’ and ‘history’ are 0. response_body : int : optiona
import json
import pprint
import requests
# script = """
# splash:go(args.url)
# return splash:png()
# """
resp = requests.post(
"https://kong.donavanaldrich.com/splash",
json={
"url": "http://example.com",
"history": 1,
"html": 1,
"request_body": 1,
"har": 1,
},
)
png_data = resp.content
pp = pprint.PrettyPrinter(indent=4, sort_dicts=True)
pp.pprint(png_data)
# json: {url: "http://example.com", history: 1, html: 1, request_body: 1, har: 1}
# !http POST https://kong.donavanaldrich.com/splash < json
!http POST https://kong.donavanaldrich.com/splash url=http://example.com har:=1 html:=1 png:=1 history:=1 console:=1