mirror of
https://github.com/vimagick/dockerfiles
synced 2024-06-25 16:28:40 +00: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
|
```yaml
|
||||||
splash:
|
splash:
|
||||||
image: scrapinghub/splash
|
image: scrapinghub/splash
|
||||||
command: --maxrss 4096
|
command: --maxrss 4096 --max-timeout 300
|
||||||
ports:
|
ports:
|
||||||
- "8050:8050"
|
- "8050:8050"
|
||||||
- "8051:8051"
|
- "8051:8051"
|
||||||
- "5023:5023"
|
- "5023:5023"
|
||||||
volumes:
|
volumes:
|
||||||
- ./splash/proxy-profiles:/etc/splash/proxy-profiles
|
- ./data/filters:/etc/splash/filters
|
||||||
- ./splash/js-profiles:/etc/splash/js-profiles
|
- ./data/js-profiles:/etc/splash/js-profiles
|
||||||
- ./splash/filters:/etc/splash/filters
|
- ./data/lua_modules:/etc/splash/lua_modules
|
||||||
mem_limit: 4500M
|
- ./data/proxy-profiles:/etc/splash/proxy-profiles
|
||||||
|
mem_limit: 4608M
|
||||||
restart: always
|
restart: always
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -64,12 +65,40 @@ function main(splash)
|
|||||||
end
|
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
|
```bash
|
||||||
# whole page
|
# 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
|
# only logo
|
||||||
$ http http://server:8050/execute lua_source=@youtube-logo.lua > youtube-logo.png
|
$ 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/
|
[1]: http://splash.readthedocs.org/en/latest/
|
||||||
|
Loading…
Reference in New Issue
Block a user