{"slug": "turn-a-website-task-into-an-api-you-can-call-on-rows-of-input", "title": "Turn a website task into an API you can call on rows of input", "summary": "A Browsa engineer demonstrated a pattern for turning a one-off AI agent website task into a reusable, callable API: the agent runs the task once with a JSON output schema and records the steps as a \"recipe,\" which is then replayed across rows of input to produce consistent typed columns exportable as CSV or JSON. In the example, a single agent run on books.toscrape.com took 11.1 seconds and 7 credits, while replaying the recording across three URLs took 39 seconds at 8 credits per row. The engineer noted recording does not cut per-row cost or speed on simple pages, but guarantees the same output shape and repeats recorded steps instead of re-planning.", "body_md": "*Disclosure: I work on Browsa, the cloud browser used here.*\n\nAn 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.\n\nThe example uses [books.toscrape.com](https://books.toscrape.com), a sandbox site made for scraping practice.\n\n``` python\nimport time\nfrom browsa import Client\n\nclient = Client()  # reads BROWSA_API_KEY\nBOOK = \"https://books.toscrape.com/catalogue\"\n\njob = client.run_task(\n    task=\"Open the product page and return title, price and in_stock\",\n    llm=\"browsa\",\n    initial_url=f\"{BOOK}/sharp-objects_997/index.html\",\n    output_schema={\n        \"type\": \"object\",\n        \"properties\": {\n            \"title\": {\"type\": \"string\"},\n            \"price\": {\"type\": \"string\"},\n            \"in_stock\": {\"type\": \"boolean\"},\n        },\n        \"required\": [\"title\", \"price\", \"in_stock\"],\n    },\n    record_recipe=True,\n)\nprint(f\"agent run: {job.outcome} in {job.duration_ms / 1000:.1f} s, {job.credits_charged} credits\")\nprint(job.final_result)\nagent run: completed in 11.1 s, 7 credits\n{\"price\": \"£47.82\", \"title\": \"Sharp Objects\", \"in_stock\": true}\n```\n\nTwo details matter here:\n\n`output_schema`:` answer` column.`initial_url`:` url` input of the recording.\n\n```\nrobot = client.robots.create(\n    name=\"Book prices\",\n    from_job_id=job.id,\n    inputs=[\n        {\"url\": f\"{BOOK}/sharp-objects_997/index.html\"},\n        {\"url\": f\"{BOOK}/soumission_998/index.html\"},\n        {\"url\": f\"{BOOK}/tipping-the-velvet_999/index.html\"},\n    ],\n)\nt0 = time.time()\nrun = client.robot_runs.wait(client.robots.run(robot.id).id)\nprint(f\"robot run: {run.status} in {time.time() - t0:.0f} s\")\nprint(client.robot_runs.export(run.id))  # CSV\nrobot run: completed in 39 s\nrow,status,error_code,credits,input.url,price,title,in_stock\n0,ok,,8,https://books.toscrape.com/catalogue/sharp-objects_997/index.html,£47.82,Sharp Objects,true\n1,ok,,8,https://books.toscrape.com/catalogue/soumission_998/index.html,£50.10,Soumission,true\n2,ok,,8,https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html,£53.74,Tipping the Velvet,true\n```\n\nEach 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.\n\nA row with an input the recording doesn't take is rejected before anything runs:\n\n```\nclient.robots.run(robot.id, inputs=[{\"link\": f\"{BOOK}/soumission_998/index.html\"}])\nUNKNOWN_INPUT inputs[0]: \"link\" is not a param of this recipe, so the run would ignore it; its params are \"url\"\n```\n\nRows that fail while running are free, too.\n\nA 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.", "url": "https://wpnews.pro/news/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input", "canonical_source": "https://dev.to/browsa/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input-261h", "published_at": "2026-11-24 06:08:56+00:00", "updated_at": "2026-11-24 06:12:30.136533+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Browsa", "books.toscrape.com"], "also_reported_by": [], "takeaway": "Recording an agent's successful run as a replayable recipe with a fixed output schema yields identical typed columns per input row, though at 8 credits per row it costs the same as re-running the agent and was not faster on a simple page (39 s for three rows).", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input", "markdown": "https://wpnews.pro/news/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input.md", "text": "https://wpnews.pro/news/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input.txt", "jsonld": "https://wpnews.pro/news/turn-a-website-task-into-an-api-you-can-call-on-rows-of-input.jsonld"}}