# Pricing extraction with source evidence

The benchmark compares DataSea, Firecrawl, and Bright Data on one versioned public page. Every workflow extracts the same subscription plans, copies each published price and billing interval, and returns a source quote for every non-null field. The fictional Harbor Notes fixture includes two published prices, a quote-only plan, and a one-time add-on that the extraction should exclude. [Fixture HTML](fixtures/pricing-v1.html) · [Labels and SHA-256](fixtures/pricing-v1.labels.json)

## Results

Protocol verified against the public API docs on 2026-11-20 UTC. No live provider requests or billing observations were made for this report. The default hosted fixture returned HTTP 404 during verification and should be served by the docs deployment that includes this directory. A public HTTPS mirror can be used if it serves the identical bytes without a redirect. The dated [pending report](results/2026-11-20-pending.json) contains no measurements.

| Workflow | Live quality and failures | Latency | Cost per usable row and result |
| --- | --- | --- | --- |
| DataSea Scrape | Pending | Pending | Pending |
| Firecrawl Scrape | Pending | Pending | Pending |
| Bright Data Web Unlocker + OpenAI | Pending | Pending | Pending |

## Reproduce

Use Python 3.10+ and keep `run.py` and `fixtures/` together under `benchmark/`, next to `extract.py` in its parent directory. The runner uses the Python standard library. From the checkout root, generate a dated JSON report without credentials or network calls.

```sh
cd developers/docs-site/public/examples
python3 benchmark/run.py > "pricing-pending-$(date -u +%F).json"
```

For a live test, set credentials for explicitly authorized benchmark accounts in the environment. Supply only the providers you intend to run. Each selected provider needs the variables listed below. Missing credentials leave its attempts pending. A credentialed live run checks the fixture with an unauthenticated GET before starting any provider jobs and aborts if the response is anything other than HTTP 200 with the expected SHA-256. Keep a copy of the report for scoring and billing reconciliation.

| Workflow | Environment variables |
| --- | --- |
| DataSea | `DATASEA_API_KEY` with `web:scrape` and `web:jobs:read` |
| Firecrawl | `FIRECRAWL_API_KEY` |
| Bright Data + OpenAI | `BRIGHT_DATA_API_KEY`, `BRIGHT_DATA_UNLOCKER_ZONE`, and `BENCHMARK_OPENAI_API_KEY` |

```sh
python3 benchmark/run.py --live \
  --provider datasea --provider firecrawl --provider bright-data --runs 3 \
  > "pricing-live-$(date -u +%F).json"
```

Use `--fixture-url https://…/pricing-v1.html` for a byte-identical public mirror. The exact requested URL becomes the answer key for evidence URLs. With `--runs` from 1 to 10, the runner starts one attempt per selected provider per trial and rotates provider order. Trials run sequentially. It prints returned results, failures, and pending attempts in the same report. Provider failures remain in the report and the command exits successfully when it writes that report. A preflight or input error exits nonzero.

For the standalone DataSea example, set `DATASEA_API_KEY` and run either command from the examples directory. Pass a public pricing page URL to override the hosted fixture. JSON goes to stdout and the operation key goes to stderr.

```sh
python3 extract.py
node extract.ts
```

The TypeScript example requires Node.js 22.18+ and runs directly. Both examples give the operation 180 seconds, poll every two seconds up to 90 times, and allow at most three attempts per request on transient failures. Each HTTP attempt has a 15-second cap within that deadline. They respect `Retry-After` within the operation deadline. A retry uses the same request body and `Idempotency-Key`. If a submission outcome is unknown, rerun the same command with the previous key in `DATASEA_IDEMPOTENCY_KEY`. Use a new key for each distinct extraction. Polling deadlines are client-side. If a job is still processing after the deadline, use its job ID to check the final outcome. [DataSea OpenAPI](https://developers.datasea.io/openapi.yaml)

To run both example CLIs and all provider adapters against local HTTP stubs, run this command from the checkout root. The tests use synthetic responses and charges.

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s developers/docs-site/tests/examples -v
```

## Provider paths

- **DataSea Scrape** sends `POST https://api.datasea.io/v1/scrape` with the scoped key in `X-API-Key`, a fresh `Idempotency-Key`, and `mode: "async"`. The body requests `options.formats: ["json"]`, `options.json.schema` and `options.json.instruction`, no browser render, derived cache bypass, and a 30-second acquisition budget. Poll `GET https://api.datasea.io/v1/jobs/{jobId}`. Read `data.result.outputs.json` for rows, evidence, and missing pointers. The service provides evidence source URLs. Job UUID, request ID, and returned usage, including final settled credits when available, are recorded. [DataSea OpenAPI](https://developers.datasea.io/openapi.yaml)
- **Firecrawl Scrape** sends a bearer-authenticated `POST https://api.firecrawl.dev/v2/scrape` with one URL and a `formats` entry of `{type: "json", schema, prompt}`. It sets `maxAge: 0`, `storeInCache: false`, `onlyMainContent: false`, and a 150-second provider timeout. Read `data.json`. The schema asks for an evidence pointer and full quote, and the runner attaches `data.metadata.url` to each citation. If that field is absent, the runner uses `data.metadata.sourceURL` and records that it is the requested URL. [Scrape API](https://docs.firecrawl.dev/api-reference/endpoint/scrape.md) · [Firecrawl JSON mode](https://docs.firecrawl.dev/features/llm-extract.md)
- **Bright Data Web Unlocker + OpenAI** sends a bearer-authenticated `POST https://api.brightdata.com/request` with the Unlocker zone, URL, `format: "raw"`, `data_format: "markdown"`, `render: "false"`, and `debug: true`. The runner reads the raw Markdown and records selected `X-BRD-Debug` fields when present. It then sends the Markdown to `POST https://api.openai.com/v1/chat/completions` using `gpt-4.1-mini-2025-04-14`, temperature 0, a 2,048 completion-token cap, and strict `response_format.type: "json_schema"`. It reads `choices[0].message.content`, records model usage if available, and attaches the requested URL to each quote. This workflow measures a separate extraction model alongside Bright Data acquisition. [Unlocker REST API](https://docs.brightdata.com/api-reference/rest-api/unlocker/unlock-website.md) · [Markdown and debug fields](https://docs.brightdata.com/products/web-unlocker/features.md) · [Chat Completions](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create) · [Model snapshot](https://platform.openai.com/docs/models/gpt-4.1-mini)

## Scoring and measurement

- Match plans by name without regard to output order. Compare extracted values and quotes after collapsing whitespace, with case and punctuation preserved. Each non-null value must match the label. Its citation must use the corresponding JSON Pointer, the entire labeled source sentence, and the fixture URL.
- For a returned plan, count fields that are correctly null or omitted, unexpectedly missing, incorrectly populated, or filled despite having no published value. Missing plans count separately. Missing pointers are taken from DataSea's response and derived from the returned rows for the other workflows. A quote-only plan is correct with its name and evidence present and its price and billing interval empty.
- A **usable row** is a uniquely returned plan with a published price and interval whose values and evidence all match. A **usable result** is one attempt with every expected plan correctly extracted and cited, including the quote-only plan, with no extra rows, invented fields, mismatched missing pointers, or invalid citations. The report records row and field counts for each structured response. API and response failures are reported separately from structured responses that fail those quality checks.
- Attempt latency uses a monotonic client clock from submission to structured output or failure. It includes networking, DataSea retries and polling cadence, and both Bright Data pipeline calls. It excludes fixture preflight, scoring, and billing reconciliation. Per-provider minimum, median, and maximum include failed attempts. The 180-second client deadline does not guarantee that providers stop or settle usage by then. The runner does not automatically retry Firecrawl, Bright Data, or OpenAI POSTs.
- Keep fixture digest and URL, workflow options, provider accounts and plans, runner clock/location, and UTC test window with the report. The fixture uses static HTML and requires no JavaScript or geo-specific content. Cache options are requested where documented here. Provider caches, backend rendering and model choices, provider-side retries, and service load are not equivalent or observable across all three paths. Polling can add about two seconds to an otherwise successful DataSea job. Treat results as observations for this fixture and configuration. A small run provides no general provider ranking.

## Billing and cost per usable output

The runner preserves provider-native usage for reconciliation. Credits, tokens, and a billable flag are different units. Dollar fields stay pending until actual, attributable USD charges are available. Use dated accounting records from the accounts used for the run. Include charges for failed and timed-out attempts and both Bright Data pipeline components. Record an observed zero only when the accounting record or trace confirms zero, including a stage that was never called after an earlier failure. If the source only reports credits, tokens, a shared aggregate, or a plan price without a reconciled run-level charge, leave the affected cost pending. Do not enter credentials, customer records, or private account details in a report.

Create a billing JSON file keyed by the saved report's `runId` and its `attemptId` values. Each component takes an observed USD decimal string, a reference to the supporting record, and a UTC observation date. The placeholders below describe the format. Use the component keys `datasea`, `firecrawl`, or both `bright-data` and `openai` as appropriate.

```json
{
  "runId": "<report runId>",
  "attempts": {
    "bright-data-1": {
      "bright-data": {
        "usd": "<observed USD decimal>",
        "reference": "<sanitized billing reference>",
        "observedAt": "<ISO 8601 UTC timestamp>"
      },
      "openai": {
        "usd": "<observed USD decimal>",
        "reference": "<sanitized billing reference>",
        "observedAt": "<ISO 8601 UTC timestamp>"
      }
    }
  }
}
```

Recompute quality and costs offline from the saved output.

```sh
python3 benchmark/run.py --rescore pricing-live-YYYY-MM-DD.json \
  --billing observed-billing.json > pricing-reconciled-YYYY-MM-DD.json
```

The runner sums observed charges across all started attempts for a provider. It divides that total by the total usable rows and separately by the number of usable results. Until every started attempt's components have an observed USD amount, all three dollar fields remain pending. A zero denominator leaves the corresponding ratio empty even after billing has been reconciled.
