simonw / simonw/shot-scraper

[Feature] Support executing playwright code (--eval)

Open
#178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
128
Avg merge
9d 15h
Merged PRs (30d)
2

Description

javascript is a useful function but lacks many of the niceties provided by playwright. It would be nice to be able to make use of playwright by providing an eval-unsafe (or playwright?) subcommand that evaluates playwright code in the scope of the "page" variable.

This feature would also make it much easier to run simple one-off playwright scripts without all of the package/project management and page setup boilerplate code. e.g. shot-scraper --eval-unsafe 'page.querySelector('a').getAttribute('href').

Obviously 'eval' is in general a security risk but shouldn't be a problem in the context of non-server facing code (which is a minority use case in shot-scraper?). It should be explicitly labeled as unsafe: e.g. --eval-unsafe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing javascript CLI function and command parsing, then trace how the page variable is created. The requested behavior is an explicitly unsafe eval subcommand that evaluates code in the page scope; done means a one-off Playwright-style expression can run without project boilerplate and the unsafe nature is clearly labeled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.