From 08bcf6d0c1d128f06b34a4cf15bd3c480746a122 Mon Sep 17 00:00:00 2001 From: kev Date: Fri, 6 Jan 2017 18:13:03 +0800 Subject: [PATCH] update splash --- splash/README.md | 30 ++++++++++++++++++++---------- splash/docker-compose.yml | 13 +++++++------ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/splash/README.md b/splash/README.md index cf204b6..46d51b6 100644 --- a/splash/README.md +++ b/splash/README.md @@ -1,7 +1,7 @@ splash ====== -[`Splash`][1] is a javascript rendering service with an HTTP API. It's a +[Splash][1] is a javascript rendering service with an HTTP API. It's a lightweight browser with an HTTP API, implemented in Python using Twisted and QT. @@ -9,7 +9,7 @@ It's fast, lightweight and state-less which makes it easy to distribute. ## docker-compose.yml -``` +```yaml splash: image: scrapinghub/splash command: --maxrss 4096 @@ -33,14 +33,14 @@ $ cd ~/fig/splash $ tree . ├── docker-compose.yml -└── splash +└── data ├── filters │   ├── easylist.txt │   └── default.txt ├── js-profiles └── proxy-profiles -$ cat splash/filters/default.txt +$ cat data/filters/default.txt ||fonts.googleapis.com^ ||ajax.googleapis.com^ @@ -53,13 +53,23 @@ $ docker-compose up -d ## client -``` -$ http --proxy http:http://server:8051 http://stackoverflow.com x-splash-render:json x-splash-html:1 x-splash-png:1 x-splash-iframes:1 x-splash-har:1 > so.json -$ jq .har so.json | pbcopy -$ open http://www.softwareishard.com/har/viewer/ +```lua +-- youtube-logo.lua -$ http --proxy http:http://server:8051 http://stackoverflow.com x-splash-render:png > so.png -$ open so.png +function main(splash) + splash:go('https://www.youtube.com/') + splash:wait(0.5) + local logo = splash:select('.logo') + return logo:png() +end +``` + +```bash +# whole page +$ http http://server:8050/render.png url==https://www.youtube.com > youtube.png + +# only logo +$ http http://server:8050/execute lua_source=@youtube-logo.lua > youtube-logo.png ``` [1]: http://splash.readthedocs.org/en/latest/ diff --git a/splash/docker-compose.yml b/splash/docker-compose.yml index d361f87..633ffd9 100644 --- a/splash/docker-compose.yml +++ b/splash/docker-compose.yml @@ -1,13 +1,14 @@ splash: - image: vimagick/splash - command: --maxrss 4096 + image: scrapinghub/splash + command: --maxrss 4096 --max-timeout 300 ports: - "8050:8050" - "8051:8051" - "5023:5023" volumes: - - ./splash/proxy-profiles:/etc/splash/proxy-profiles - - ./splash/js-profiles:/etc/splash/js-profiles - - ./splash/filters:/etc/splash/filters - mem_limit: 4500M + - ./data/filters:/etc/splash/filters + - ./data/js-profiles:/etc/splash/js-profiles + - ./data/lua_modules:/etc/splash/lua_modules + - ./data/proxy-profiles:/etc/splash/proxy-profiles + mem_limit: 4608M restart: always