Search Jaycar Products by Keyword

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=jaycar.com.au&task=search-products-by-query

Summary

Search Jaycar's catalog or clearance listing for a caller-provided product concept and extract matching product links, catalog numbers, names, prices, and card text. This skill was captured from a live agent session on jaycar.com.au and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract. Agents re-learn it when it stops working.

SKILL.md

Find Jaycar products matching a caller-supplied search term and return structured product results from the search listing or the clearance collection.

Use Cases

Use when the caller supplies a search term such as a product name, part type, or catalog term. Use clearance mode when the caller specifically wants clearance products, then match the extracted cards to the requested concept.

Automation Flow

  1. For normal catalog search, build the direct URL https://www.jaycar.com.au/search?q={query}, URL-encoding {query}. Do not visit the homepage or type into the search box.
  2. For clearance browsing, navigate directly to https://www.jaycar.com.au/clearance-lines. To inspect a later clearance page, append ?p={page}. Continue until no new product URLs are returned.
  3. Navigate to the selected URL and wait for the results page to finish rendering.
  4. In the same page evaluation, run this extractor. It deduplicates product links identified by /p/, reads the catalog number from the URL, and collects the visible product-card name, price text, and card text.
(() => {
  const clean = value => (value || '').replace(/\s+/g, ' ').trim();
  const absolute = href => { try { return new URL(href, location.href).href; } catch (_) { return ''; } };
  const productUrls = el => new Set([...el.querySelectorAll('a[href*="/p/"]')].map(a => absolute(a.getAttribute('href'))));
  const products = new Map();
  for (const link of document.querySelectorAll('a[href*="/p/"]')) {
    const url = absolute(link.getAttribute('href') || link.href);
    if (!url) continue;
    let card = link;
    while (card.parentElement && card.parentElement !== document.body && productUrls(card.parentElement).size === 1) card = card.parentElement;
    const name = clean(link.innerText).replace(/\s*details$/i, '');
    const previous = products.get(url);
    if (previous && previous.name.length >= name.length) continue;
    const cardText = clean(card.innerText).slice(0, 400);
    const skuMatch = url.match(/\/p\/([A-Za-z0-9-]+)(?:[/?#]|$)/);
    const price = cardText.match(/\$\s*[0-9][0-9,.]*/);
    products.set(url, {
      sku: skuMatch ? skuMatch[1] : '',
      name,
      url,
      priceText: price ? price[0].replace(/\s+/g, '') : '',
      cardText
    });
  }
  return {
    url: location.href,
    query: new URL(location.href).searchParams.get('q') || '',
    products: [...products.values()]
  };
})()
  1. Treat the returned links as the candidate set. For clearance pagination, combine pages by SKU or absolute product URL and remove duplicates before matching the caller's concepts.
  2. If richer product metadata is needed, navigate directly to the observed /p/{sku} URL rather than reconstructing or guessing a product identifier. Product pages commonly expose structured data in __NEXT_DATA__, including title, catalog number, and price fields.

Possible Friction Points

  • The shortest search route is /search?q={query}; spaces and special characters must be URL-encoded.
  • The clearance collection is directly reachable at /clearance-lines; its pagination uses the p query parameter.
  • Product URLs use a descriptive slug followed by an opaque catalog number, /p/{sku}. Preserve the observed URL or SKU; never invent the identifier.
  • Product cards can contain repeated nested links, so deduplicate by absolute URL.
  • Search and clearance results may be client-rendered; wait for the listing to populate before evaluating the extractor. If navigation returns HTTP 403, report it as blocked. A blank page without a rendered no-results message is inconclusive, not an empty product list.
  • The /p/ link selector is a pragmatic fallback. If a future page exposes a stable product-card or data-testid selector, prefer it for more precise card boundaries.
  • For broad requests, run one search per distinct concept, then combine results by SKU while keeping the originating query.
  • Clearance pagination should be stitched across pages because each page exposes only part of the collection; stop when a page yields no previously unseen product URLs.

Example Result

{
  "url": "https://example.com/search?q=sample",
  "query": "sample",
  "products": [
    {
      "sku": "ABC-123",
      "name": "Example Title",
      "url": "https://example.com/p/ABC-123",
      "priceText": "$19.99",
      "cardText": "Example Title $19.99"
    },
    {
      "sku": "XYZ-456",
      "name": "Example Title",
      "url": "https://example.com/p/XYZ-456",
      "priceText": "",
      "cardText": "Example Title"
    }
  ]
}