Skip to content

Commit 18bbf98

Browse files
committed
Experimental video support
1 parent 8435690 commit 18bbf98

File tree

4 files changed

+593
-8
lines changed

4 files changed

+593
-8
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,40 @@ This will create a screenshot in a file called `datasette-io.png`.
3838

3939
Many more options are available, see [Taking a screenshot](https://shot-scraper.datasette.io/en/stable/screenshots.html) for details.
4040

41+
## Recording videos
42+
43+
You can record videos of web pages with interactive elements:
44+
45+
shot-scraper video https://example.com/ -o video.webm --duration 10
46+
47+
Pass actions directly via the command line:
48+
49+
shot-scraper video https://example.com/ -o video.webm \
50+
--actions '[{"action": "click", "selector": "#button"}]'
51+
52+
Or reference a file (JSON or YAML):
53+
54+
shot-scraper video https://example.com/ -o video.webm --actions actions.json
55+
56+
For more complex workflows, create a YAML file with action sequences:
57+
58+
```yaml
59+
- output: demo.webm
60+
video: true
61+
url: https://example.com/
62+
actions:
63+
- action: click
64+
selector: "#menu"
65+
- action: scroll
66+
y: 500
67+
- action: javascript
68+
code: document.querySelector('h1').style.color = 'red';
69+
```
70+
71+
Then run: `shot-scraper multi config.yml`
72+
73+
See [Recording videos](https://shot-scraper.datasette.io/en/stable/video.html) for full documentation.
74+
4175
## Examples
4276

4377
- The [shot-scraper-demo](https://github.com/simonw/shot-scraper-demo) repository uses this tool to capture recently spotted owls in El Granada, CA according to [this page](https://www.owlsnearme.com/?place=127871), and to generate an annotated screenshot illustrating a Datasette feature as described [in my blog](https://simonwillison.net/2022/Mar/10/shot-scraper/#a-complex-example).

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ installation
2323
screenshots
2424
authentication
2525
multi
26+
video
2627
javascript
2728
pdf
2829
html

docs/multi.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@ With that server configured, you can now take screenshots of `http://localhost:8
167167
```
168168
The server process will be automatically terminated when the `shot-scraper multi` command completes, unless you pass the `--leave-server` option to `shot-scraper multi` in which case it will be left running - you can terminate it using `kill PID` with the PID displayed in the console output.
169169

170+
## Recording videos
171+
172+
You can record videos instead of screenshots by adding `video: true` to a YAML block. Videos support an `actions:` list for defining interactions to perform during recording:
173+
174+
```yaml
175+
- output: demo.webm
176+
video: true
177+
url: https://example.com/
178+
duration: 5
179+
actions:
180+
- action: click
181+
selector: "#menu"
182+
- action: wait
183+
ms: 1000
184+
- action: scroll
185+
y: 500
186+
```
187+
188+
See {ref}`video` for full documentation on video recording and available actions.
189+
170190
## Running custom code between steps
171191

172192
If you are taking screenshots of a single application, you may find it useful to run additional steps between shots that modify that application in some way.

0 commit comments

Comments
 (0)