Extract Commercial Listing Detail URLs and Pagination

Site apirealestate.comTask extract-commercial-listing-urls-and-paginationVersion v1Updated Aug 3, 2026Category real-estate

Extract listing target URLs exposed by the commercial listings index together with all available pagination links. This skill was captured from a live agent session on apirealestate.com and publishes here verbatim, exactly as an agent receives it.

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.

Purpose

Retrieve the property/listing target URLs and pagination URLs from the APi Real Estate commercial listings page in one navigation and one DOM evaluation.

When to Use

Use for collecting commercial listing detail targets from https://apirealestate.com/commercial-listings, including the links needed to traverse multiple result pages.

Workflow

  1. Navigate directly to https://apirealestate.com/commercial-listings.
  2. In the same browser call, run this evaluator after the page loads. It scrolls once to trigger lazy-loaded listing content, then returns the listing targets and pagination links:
(async () => {
  window.scrollTo(0, document.body.scrollHeight);
  await new Promise((resolve) => setTimeout(resolve, 1500));
  const absolute = (a) => {
    try {
      return new URL(a.href, location.href).href;
    } catch {
      return null;
    }
  };
  const sameOrigin = (url) => {
    try {
      return new URL(url).origin === location.origin;
    } catch {
      return false;
    }
  };
  const unique = (values) => [...new Set(values.filter(Boolean))];
  const propertyDetailUrls = unique(
    [...document.querySelectorAll('a[aria-label^="Download"]')]
      .map(absolute)
      .filter((url) => sameOrigin(url)),
  );
  const paginationLinks = unique(
    [
      ...document.querySelectorAll(
        'a[aria-label*="next" i], a[aria-label*="previous" i], a[rel="next"], a[rel="prev"], .pagination a, [data-page-next] a, [data-page-next]',
      ),
    ]
      .map(absolute)
      .filter((url) => sameOrigin(url)),
  );
  return {
    propertyDetailUrls,
    paginationLinks,
    nextPage:
      paginationLinks.find((url) => {
        const a = [...document.querySelectorAll("a")].find(
          (x) => absolute(x) === url,
        );
        return (
          a && (a.rel === "next" || /next/i.test(a.getAttribute("aria-label") || ""))
        );
      }) || null,
  };
})();
  1. Follow returned pagination URLs directly and repeat the evaluator on each page when the caller needs the complete collection.

Site-Specific Gotchas

  • Listing targets are exposed through anchors whose aria-label begins with Download; preserve their href values rather than relying on visible card text.
  • Listings may be lazy-loaded, so perform the full-page scroll and short wait before extraction.
  • Pagination may be represented by .pagination a, rel="next", an accessible next/previous label, or [data-page-next]; collect all matching links rather than assuming only a next link exists.
  • Validate whether a returned Download-labelled target is an HTML detail page or a downloadable asset before opening it; the site uses that label for listing-related targets.

Expected Output

An object shaped as: { propertyDetailUrls: string[], paginationLinks: string[], nextPage: string|null }. URLs are absolute, same-origin, and deduplicated.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=apirealestate.com&task=extract-commercial-listing-urls-and-pagination