{ "cells": [ { "cell_type": "markdown", "id": "f1543948-4781-4f50-849e-1e8b9786b7bb", "metadata": {}, "source": [ "# Splash" ] }, { "cell_type": "code", "execution_count": 27, "id": "8aaec01c-4b87-4949-8787-e9dec8b2e5dd", "metadata": { "execution": { "iopub.execute_input": "2021-10-26T03:50:20.355782Z", "iopub.status.busy": "2021-10-26T03:50:20.355387Z", "iopub.status.idle": "2021-10-26T03:50:20.870039Z", "shell.execute_reply": "2021-10-26T03:50:20.855218Z", "shell.execute_reply.started": "2021-10-26T03:50:20.355743Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(b'{\"url\": \"http://example.com/\", \"requestedUrl\": \"http://example.com/\", \"geome'\n", " b'try\": [0, 0, 1024, 768], \"title\": \"Example Domain\", \"html\": \"'\n", " b'
\\\\nThis domain is for use in illustr'\n", " b'ative examples in documents. You may use this\\\\n domain in literature '\n", " b'without prior coordination or asking for permission.
\\\\n \\\\n<'\n", " b'/div>\\\\n\\\\n\\\\n\", \"history\": [], \"har\": {\"log\": {\"version\": \"1'\n", " b'.2\", \"creator\": {\"name\": \"Splash\", \"version\": \"3.5\"}, \"browser\": {\"name\": \"Q'\n", " b'WebKit\", \"version\": \"602.1\", \"comment\": \"PyQt 5.14.2, Qt 5.14.1\"}, \"entries\"'\n", " b': [], \"pages\": [{\"id\": \"1\", \"title\": \"Example Domain\", \"startedDateTime\": \"2'\n", " b'021-10-26T03:50:20.767475Z\", \"pageTimings\": {\"onContentLoad\": 4, \"onLoad\": 2'\n", " b'3, \"_onStarted\": 1, \"_onPrepareStart\": 23, \"_onIframesRendered\": 24}}]}}}')\n" ] } ], "source": [ "import json\n", "import pprint\n", "\n", "import requests\n", "\n", "resp = requests.post(\n", " \"https://kong.donavanaldrich.com/splash\",\n", " json={\n", " \"url\": \"http://example.com\",\n", " \"history\": 1,\n", " \"html\": 1,\n", " \"request_body\": 1,\n", " \"har\": 1,\n", " },\n", ")\n", "\n", "png_data = resp.content\n", "\n", "pp = pprint.PrettyPrinter(indent=4, sort_dicts=True)\n", "pp.pprint(png_data)" ] }, { "cell_type": "code", "execution_count": 2, "id": "1630de92-c015-43a3-b747-9d29ca5afba2", "metadata": { "execution": { "iopub.execute_input": "2021-10-26T04:36:51.911804Z", "iopub.status.busy": "2021-10-26T04:36:51.911422Z", "iopub.status.idle": "2021-10-26T04:36:55.323679Z", "shell.execute_reply": "2021-10-26T04:36:55.322189Z", "shell.execute_reply.started": "2021-10-26T04:36:51.911765Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Collecting httpie\n", " Downloading httpie-3.2.1-py3-none-any.whl (124 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m125.0/125.0 KB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hRequirement already satisfied: pip in /usr/lib/python3/dist-packages (from httpie) (22.0.2)\n", "Requirement already satisfied: multidict>=4.7.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from httpie) (6.0.2)\n", "Requirement already satisfied: requests[socks]>=2.22.0 in /usr/lib/python3/dist-packages (from httpie) (2.25.1)\n", "Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from httpie) (59.6.0)\n", "Requirement already satisfied: rich>=9.10.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from httpie) (12.4.4)\n", "Requirement already satisfied: defusedxml>=0.6.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from httpie) (0.7.1)\n", "Collecting requests-toolbelt>=0.9.1\n", " Using cached requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB)\n", "Requirement already satisfied: Pygments>=2.5.2 in /home/donaldrich/.local/lib/python3.10/site-packages (from httpie) (2.12.0)\n", "Collecting charset-normalizer>=2.0.0\n", " Using cached charset_normalizer-2.1.0-py3-none-any.whl (39 kB)\n", "Collecting PySocks!=1.5.7,>=1.5.6\n", " Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)\n", "Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from rich>=9.10.0->httpie) (0.9.1)\n", "Installing collected packages: requests-toolbelt, PySocks, charset-normalizer, httpie\n", "Successfully installed PySocks-1.7.1 charset-normalizer-2.1.0 httpie-3.2.1 requests-toolbelt-0.9.1\n", "Note: you may need to restart the kernel to use updated packages.\n", "\u001b[34mHTTP\u001b[39;49;00m/\u001b[34m1.1\u001b[39;49;00m \u001b[34m404\u001b[39;49;00m \u001b[36mNot Found\u001b[39;49;00m\n", "\u001b[36mCF-Cache-Status\u001b[39;49;00m: DYNAMIC\n", "\u001b[36mCF-RAY\u001b[39;49;00m: 738eaac46e3e9f0a-DFW\n", "\u001b[36mConnection\u001b[39;49;00m: keep-alive\n", "\u001b[36mContent-Length\u001b[39;49;00m: 0\n", "\u001b[36mDate\u001b[39;49;00m: Thu, 11 Aug 2022 05:45:47 GMT\n", "\u001b[36mExpect-CT\u001b[39;49;00m: max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"\n", "\u001b[36mNEL\u001b[39;49;00m: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\n", "\u001b[36mReport-To\u001b[39;49;00m: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=KMwuG83peUj0Eb0KdC4TpbV04BRgFZJfc9kuZ0pAAB7i3CBBxRPPQvw6BJrQgw1FgPGvY1cxMOHPpWfm4ioawmG8T73vyyOB0Jy8424rGniO5s7VJlDc2kbHzGlBx1EwE3cnNxcfK45pZg%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\n", "\u001b[36mServer\u001b[39;49;00m: cloudflare\n", "\u001b[36mStrict-Transport-Security\u001b[39;49;00m: max-age=15552000; includeSubDomains; preload\n", "\u001b[36mX-Content-Type-Options\u001b[39;49;00m: nosniff\n", "\u001b[36maccess-control-allow-credentials\u001b[39;49;00m: true\n", "\u001b[36maccess-control-allow-origin\u001b[39;49;00m: donavanaldrich.com\n", "\u001b[36maccess-control-expose-headers\u001b[39;49;00m: Origin,Authorization\n", "\u001b[36malt-svc\u001b[39;49;00m: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\n", "\u001b[36mratelimit-limit\u001b[39;49;00m: 5\n", "\u001b[36mratelimit-remaining\u001b[39;49;00m: 4\n", "\u001b[36mratelimit-reset\u001b[39;49;00m: 1\n", "\u001b[36mvary\u001b[39;49;00m: Origin\n", "\u001b[36mvia\u001b[39;49;00m: kong/2.8.1\n", "\u001b[36mwww-authenticate\u001b[39;49;00m: Key realm=\"kong\"\n", "\u001b[36mx-cache-status\u001b[39;49;00m: Bypass\n", "\u001b[36mx-kong-proxy-latency\u001b[39;49;00m: 16\n", "\u001b[36mx-kong-upstream-latency\u001b[39;49;00m: 119\n", "\u001b[36mx-ratelimit-limit-minute\u001b[39;49;00m: 60\n", "\u001b[36mx-ratelimit-limit-second\u001b[39;49;00m: 5\n", "\u001b[36mx-ratelimit-remaining-minute\u001b[39;49;00m: 59\n", "\u001b[36mx-ratelimit-remaining-second\u001b[39;49;00m: 4\n", "\n", "\n", "\n" ] } ], "source": [ "%pip install httpie\n", "\n", "!http POST https://kong.donavanaldrich.com/splash url=http://example.com har:=1 html:=1 png:=1 history:=1 console:=1" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.4 64-bit", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.4" }, "vscode": { "interpreter": { "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" } } }, "nbformat": 4, "nbformat_minor": 5 }