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
- 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. - 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. - Navigate to the selected URL and wait for the results page to finish rendering.
- 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()]
};
})()- 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.
- 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 thepquery 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"
}
]
}