Skip to main content
All examples on this page work against books.toscrape.com and quotes.toscrape.com, two public sites built for scraping practice. Copy any example, paste it into the API, and it will work as shown.

1. Simple Page Scraping: No Actions Needed

When the content you want is fully visible on one page, you do not need actions at all. Just send the URL with a prompt and let the AI extract what you need. Use this when: the list is short, fits on one page, and does not require any clicking.
Response:
The page has 10 quotes. A prompt handles all 10 easily without any forEach. If the same site had 200 quotes across 20 pages, that is when you would reach for forEach with pagination.

2. Dismiss a banner, then scrape

Some pages load a cookie banner or modal that blocks the content. Click it away before the scrape runs. Use this when: a consent banner or popup is covering the content.

3. Search, wait for results, then scrape

Type a search query and scrape the results page. Use this when: the content only appears after submitting a search form.

4. Inline forEach: Collect a List with itemPrompt

Process every card on a page without navigating away from it. Each card’s content is read directly and passed through itemPrompt for AI extraction. Use this when: all the data is visible on the listing page itself and you want a clean, structured result per item.
Response (result.content):

5. Inline forEach with Pagination: Collect Across Multiple Pages

When a listing spans multiple pages, use pagination to keep collecting after the first page is exhausted. Use this when: the catalogue has a “Next” button and you need more items than fit on one page.
This collects up to 30 quotes, following the Next link across up to 3 extra pages. It stops as soon as it hits 30 total or runs out of pages. Response (result.content):

Click into each product page to capture the rich detail that only exists there. This gives you descriptions, specifications, availability, and anything else that is not on the listing page. Use this when: the listing page only shows a preview and the full content is on the individual item page.
Response (result.content):
Navigate mode loads a full page per item, so it is slower than inline. Keep maxItems reasonable (6–10) unless you have a lot of time to spare.

7. Click a category first, then forEach navigate

Use an action to navigate to a specific section of the site before the forEach starts. The forEach runs on whatever page the browser is on after your pre-actions finish. Use this when: the items you want are behind a category link, tab, or filter on the homepage.
Response (result.content):

8. Click using plain English, then forEach with pagination

When you do not know the exact CSS selector for a navigation element, describe it in plain English using the value field on a click action. Spidra uses AI to locate the element and click it, then the forEach runs on the resulting page. Use this when: the element you need to click does not have a stable CSS selector or is easier to describe in words.

9. Scrape multiple categories in one request

Pass up to 3 URLs in a single request. Spidra processes all of them in parallel and returns one result per URL. Use this when: you need data from several categories, brands, or pages at the same time.
The response data array has three entries, one per URL, each with their own list of books. The whole thing runs in parallel, not sequentially.

10. Navigate + per-item scroll to reveal hidden content

After navigating to each item’s page, scroll down before capturing. Some pages lazy-load their content or hide a full description below the fold. Use this when: the destination page has content that only appears after scrolling, such as full product descriptions, reviews, and spec tables.
What happens step by step:
  1. Opens the homepage
  2. Clicks the Poetry category link
  3. Finds all book title links
  4. For each book (up to 3): navigates to the book page, waits 1 second, scrolls to 50% to load the full description, captures the product area, runs AI extraction
  5. Combines all results into numbered items
Response (result.content):

11. Click Mode: Expand Items and Capture Modal Content

For pages where clicking an item opens a modal, drawer, or expanded section (such as hotel room cards or FAQ accordions), use click mode to open each one, capture its content, and move on. Use this when: the detail content only appears after clicking an element on the page, inside the same page.
Response (result.content):
If no modal appears after clicking, Spidra falls back to capturing the full page.

12. Full Pipeline: Navigate, Paginate, and Extract

Combine forEach pagination with a top-level prompt to get a final clean output. itemPrompt handles per-item extraction during scraping. The top-level prompt does a final pass to restructure all items together. Use this when: you want structured data from a multi-page catalogue in one clean API response.
itemPrompt runs on each book page as it is scraped. When all 20 are collected, the top-level prompt takes the combined output and sorts the final list. Response:

Choosing the right pattern