mirror of
https://github.com/vimagick/dockerfiles.git
synced 2024-11-28 09:08:50 +02:00
add splash example
This commit is contained in:
parent
246a890c7a
commit
8ac1bff50d
@ -12,16 +12,17 @@ It's fast, lightweight and state-less which makes it easy to distribute.
|
||||
```yaml
|
||||
splash:
|
||||
image: scrapinghub/splash
|
||||
command: --maxrss 4096
|
||||
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
|
||||
```
|
||||
|
||||
@ -64,12 +65,40 @@ function main(splash)
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
-- crop.lua
|
||||
|
||||
function main(splash)
|
||||
local url = splash.args.url
|
||||
local css1 = splash.args.css1
|
||||
local css2 = splash.args.css2
|
||||
assert(splash:go(url))
|
||||
splash:set_viewport_full()
|
||||
local box1 = splash:select(css1):bounds()
|
||||
local box2 = splash:select(css2):bounds()
|
||||
return splash:png{
|
||||
region={
|
||||
math.min(box1.left, box2.left),
|
||||
math.min(box1.top, box2.top),
|
||||
math.max(box1.right, box2.right),
|
||||
math.max(box1.bottom, box2.bottom),
|
||||
}
|
||||
}
|
||||
end
|
||||
```
|
||||
|
||||
```bash
|
||||
# whole page
|
||||
$ http http://server:8050/render.png url==https://www.youtube.com > youtube.png
|
||||
$ 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
|
||||
|
||||
# only form
|
||||
$ http http://server:8050/execute lua_source=@crop.lua \
|
||||
url=https://www.facebook.com/ \
|
||||
css1='#u_0_1' \
|
||||
css2='#u_0_b' > facebook-form.png
|
||||
```
|
||||
|
||||
[1]: http://splash.readthedocs.org/en/latest/
|
||||
|
Loading…
Reference in New Issue
Block a user