Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,46 @@ on: [push, pull_request]

jobs:
test:
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml
- name: Cache Playwright browsers
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright/
key: ${{ runner.os }}-browsers
- name: Install dependencies
run: |
pip install -e '.[test]'
pip install -e . --group dev
- name: Install Playwright dependencies
run: |
python -m playwright install-deps
shot-scraper install
shot-scraper install -b firefox
shot-scraper install -b webkit
- name: Test Playwright startup time
run: |
time python -c "from playwright.sync_api import sync_playwright; p = sync_playwright().start(); b = p.chromium.launch(); b.close(); p.stop(); print('OK')"
- name: Run tests
run: |
pytest
pytest -vv
- name: Check if cog needs to be run
run: |
cog --check docs/*.md
- name: Run test examples
run: |
tests/run_examples.sh
- name: Archive examples
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: examples-${{ matrix.python-version }}
path: examples/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.venv
uv.lock
__pycache__/
*.py[cod]
*$py.class
Expand Down
11 changes: 0 additions & 11 deletions Pipfile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Options:
--timeout INTEGER Wait this many milliseconds before failing
--media-screen Use screen rather than print styles
--landscape Use landscape orientation
--format [Letter|Legal|Tabloid|Ledger|A0|A1|A2|A3|A4|A5|A6]
--format [letter|legal|tabloid|ledger|a0|a1|a2|a3|a4|a5|a6]
Which standard paper size to use
--width TEXT PDF width including units, e.g. 10cm
--height TEXT PDF height including units, e.g. 10cm
Expand Down
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[project]
name = "shot-scraper"
version = "1.8"
description = "A command-line utility for taking automated screenshots of websites"
readme = "README.md"
requires-python = ">=3.10"
license = "Apache-2.0"
authors = [
{ name = "Simon Willison" }
]

classifiers = [
"License :: OSI Approved :: Apache Software License",
]

dependencies = [
"click",
"PyYAML",
"playwright",
"click-default-group",
]

[project.urls]
Homepage = "https://shot-scraper.datasette.io/"
Issues = "https://github.com/simonw/shot-scraper/issues"
CI = "https://github.com/simonw/shot-scraper/actions"
Changelog = "https://github.com/simonw/shot-scraper/releases"

[project.scripts]
shot-scraper = "shot_scraper.cli:cli"

[dependency-groups]
dev = [
"pytest",
"cogapp",
"pytest-mock",
]
docs = [
"furo==2023.9.10",
"sphinx-autobuild",
"sphinx-copybutton",
"myst-parser",
"cogapp",
]

[build-system]
requires = ["uv_build>=0.9.18,<0.10.0"]
build-backend = "uv_build"

[tool.uv.build-backend]
module-root = ""
37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

18 changes: 9 additions & 9 deletions tests/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ shot-scraper 'https://www.owlsnearme.com/?place=127871' \
-o examples/owlsnearme-wait.jpg \
--wait-for "!!document.querySelector('section.secondary')"
# Accessibility
shot-scraper accessibility https://datasette.io/ \
> examples/datasette-accessibility.json
shot-scraper accessibility https://simonwillison.net \
--javascript "document.getElementById('wrapper').style.display='none'" \
> examples/simonwillison-accessibility-javascript.json
shot-scraper accessibility https://simonwillison.net \
--javascript "document.getElementById('wrapper').style.display='none'" \
--output examples/simonwillison-accessibility-javascript-and-dash-output.json
shot-scraper accessibility examples/local.html -o examples/local-accessibility.json
# #shot-scraper accessibility https://datasette.io/ \
# > examples/datasette-accessibility.json
# shot-scraper accessibility https://simonwillison.net \
# --javascript "document.getElementById('wrapper').style.display='none'" \
# > examples/simonwillison-accessibility-javascript.json
# shot-scraper accessibility https://simonwillison.net \
# --javascript "document.getElementById('wrapper').style.display='none'" \
# --output examples/simonwillison-accessibility-javascript-and-dash-output.json
# shot-scraper accessibility examples/local.html -o examples/local-accessibility.json
# PDF
(cd examples && shot-scraper pdf https://datasette.io/tools)
shot-scraper pdf https://datasette.io \
Expand Down