An open API service indexing awesome lists of open source software.

https://github.com/elliotwutingfeng/take_a_shot

Capture screenshot and/or HTML source code data of any given webpage and print it to stdout.
https://github.com/elliotwutingfeng/take_a_shot

chromedriver docker html javascript osint screenshot selenium source-code

Last synced: about 2 months ago
JSON representation

Capture screenshot and/or HTML source code data of any given webpage and print it to stdout.

Awesome Lists containing this project

README

          

Take A Shot


Lens


Capture screenshot and/or HTML source code data of any given webpage and print it to stdout.


Output format: JSON string containing b64-encoded data.


Python
Docker
Google Chrome


MIT license

## Implementation details

- Uses Google Chrome in headless mode.
- Works well even with vertically long webpages.
- Webpages with fixed headers generally work well, but fixed footers may lead to unusual results.

Forked and modified from:

## Requirements

Tested on the following environment

### Linux

- Linux 6.12
- Docker Version 28.3.0

## Usage

### Build

```bash
./build
```

Then either run

```bash
./capture [options]
```

or alternatively run

```bash
docker run --cap-drop=all --security-opt=no-new-privileges --rm elliotwutingfeng/take_a_shot [options]
```

## Output Format

```json
{
"screenshot": "",
"source_code": ""
}
```

## Examples

### Default User Agent

```bash
docker run --cap-drop=all --security-opt=no-new-privileges --rm elliotwutingfeng/take_a_shot "https://example.com"
```

### Specify User Agent

```bash
docker run --cap-drop=all --security-opt=no-new-privileges --rm elliotwutingfeng/take_a_shot "https://example.com" --window-size 390x844 --ua 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/113.0 Mobile/15E148 Safari/605.1.15'
```

## Help

```bash
usage: takeashot.py [-h] [--screenshot] [--source-code]
[--window-size WINDOW_SIZE] [--ua USER_AGENT]
[--wait WAIT] [--lang LANG] [--language LANGUAGE] [-v]
[--vv]
url

positional arguments:
url specify URL

options:
-h, --help show this help message and exit
--screenshot Take screenshot
--source-code Extract source code
--window-size WINDOW_SIZE
specify window size like 1200x800
--ua USER_AGENT specify user-agent
--wait WAIT specify wait seconds after scroll down
--lang LANG set LANG environment variable
--language LANGUAGE set LANGUAGE environment variable
-v set LogLevel to INFO
--vv set LogLevel to DEBUG
```

## Credits

[More Information](CREDITS.md)