# Turn a website task into an API you can call on rows of input

> Source: <https://dev.to/browsa/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input-261h>
> Published: 2026-11-24 06:08:56+00:00

**Recommendation:** Record a successful agent run as a recipe with a strict output schema, then replay it across input rows to get consistent typed columns instead of re-planning the task each time.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

*Disclosure: I work on Browsa, the cloud browser used here.*

An AI agent is good at working out how to do something on a website. It's a waste to have it work it out again for every row of a spreadsheet. The pattern this post shows: let the agent do the task once, record what it did, then replay the recording on each input and get the same typed columns every time.

The example uses [books.toscrape.com](https://books.toscrape.com), a sandbox site made for scraping practice.

``` python
import time
from browsa import Client

client = Client()  # reads BROWSA_API_KEY
BOOK = "https://books.toscrape.com/catalogue"

job = client.run_task(
    task="Open the product page and return title, price and in_stock",
    llm="browsa",
    initial_url=f"{BOOK}/sharp-objects_997/index.html",
    output_schema={
        "type": "object",
        "properties": {
            "title": {"type": "string"},
            "price": {"type": "string"},
            "in_stock": {"type": "boolean"},
        },
        "required": ["title", "price", "in_stock"],
    },
    record_recipe=True,
)
print(f"agent run: {job.outcome} in {job.duration_ms / 1000:.1f} s, {job.credits_charged} credits")
print(job.final_result)
agent run: completed in 11.1 s, 7 credits
{"price": "£47.82", "title": "Sharp Objects", "in_stock": true}
```

Two details matter here:

`output_schema`:` answer` column.`initial_url`:` url` input of the recording.

```
robot = client.robots.create(
    name="Book prices",
    from_job_id=job.id,
    inputs=[
        {"url": f"{BOOK}/sharp-objects_997/index.html"},
        {"url": f"{BOOK}/soumission_998/index.html"},
        {"url": f"{BOOK}/tipping-the-velvet_999/index.html"},
    ],
)
t0 = time.time()
run = client.robot_runs.wait(client.robots.run(robot.id).id)
print(f"robot run: {run.status} in {time.time() - t0:.0f} s")
print(client.robot_runs.export(run.id))  # CSV
robot run: completed in 39 s
row,status,error_code,credits,input.url,price,title,in_stock
0,ok,,8,https://books.toscrape.com/catalogue/sharp-objects_997/index.html,£47.82,Sharp Objects,true
1,ok,,8,https://books.toscrape.com/catalogue/soumission_998/index.html,£50.10,Soumission,true
2,ok,,8,https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html,£53.74,Tipping the Velvet,true
```

Each row replays the recording on its own URL. The columns are the ones from the schema, and the CSV (or JSON) is ready for a sheet or a database.

A row with an input the recording doesn't take is rejected before anything runs:

```
client.robots.run(robot.id, inputs=[{"link": f"{BOOK}/soumission_998/index.html"}])
UNKNOWN_INPUT inputs[0]: "link" is not a param of this recipe, so the run would ignore it; its params are "url"
```

Rows that fail while running are free, too.

A row costs the same credits as the agent task it was recorded from: here, 8 per row. Recording doesn't make a row cheaper, and on a page this simple it isn't faster either (39 s for three rows). What it buys you is the same JSON shape on every row, a typed table you can export, and runs that repeat the recorded steps instead of planning them again.
