# Quick Start

This guide walks you through taking your first screenshot with nokap in under a minute. We'll cover the three main input modes (capturing a live URL, a local HTML file, and raw HTML strings) so you can choose the approach that fits your workflow. Each example is self-contained and ready to copy into a script or notebook.

## Your First Screenshot

The simplest use of nokap is capturing a web page as a PNG:

``` python
import nokap

nokap.webshot("https://example.com", "example.png")
```

This launches headless Chrome (if not already running), navigates to the URL, captures the full page, and saves it as a PNG file.

## Screenshot a Local HTML File

You can also capture local HTML files:

``` python
nokap.webshot("page.html", "page.png")
```

nokap automatically converts local paths to `file://` URLs.

## From an HTML String

The [from_html()](../reference/from_html.md#nokap.from_html) function is designed for rendering HTML content directly, which is great for libraries that generate HTML:

``` python
html = """
<html>
<body style="font-family: system-ui; padding: 2rem;">
  <h1>Hello, nokap!</h1>
  <p>This is rendered from a string.</p>
</body>
</html>
"""

nokap.from_html(html, "hello.png")
```

## Capture a Specific Element

Use a CSS selector to capture just one element:

``` python
nokap.webshot(
    "https://example.com",
    "heading.png",
    selector="h1"
)
```

## Generate a PDF

Change the output extension to `.pdf`:

``` python
nokap.webshot("https://example.com", "page.pdf")
```

PDF options like page size, margins, and orientation are available:

``` python
nokap.webshot(
    "https://example.com",
    "page.pdf",
    page_size="a4",
    landscape=True,
    print_background=True,
)
```

## Retina Quality

Use `zoom` for higher resolution output:

``` python
# 2× resolution (retina)
nokap.webshot("https://example.com", "retina.png", zoom=2)
```

## Using the CLI

nokap also provides a command-line interface:

``` bash
# Screenshot a URL
nokap webshot https://example.com screenshot.png

# Capture a specific element with 2× zoom
nokap webshot https://example.com header.png -s "h1" -z 2

# Render an HTML file
nokap from-html report.html report.png --selector "table" --expand 10
```

## Cleanup

Chrome runs in the background for reuse. Clean up explicitly when done:

``` python
nokap.close()
```

This is called automatically at process exit, but explicit cleanup is good practice in long-running applications.

## Next Steps

You've seen the essentials: capturing URLs, local files, and HTML strings as images or PDFs, targeting specific elements with selectors, and using the CLI for shell-based workflows. These building blocks cover the majority of day-to-day use cases.

- [Screenshots](screenshots.md): Deep dive into image capture options
- [PDF Generation](pdf-generation.md): Full PDF configuration
- [The CLI](cli.md): Command-line usage reference

Each of the guides above expands on what you've learned here, covering every parameter in detail. Start with whichever matches your immediate need. (You don't need to read them in order.)
