Search CivilJobs Vacancies by Departmental Reference

Site civiljobs.co.ukTask search-jobs-by-departmental-referenceVersion v2Updated Aug 20, 2026Category jobs

Search civiljobs.co.uk for a departmental reference and identify matching vacancy links and titles. This skill was captured from a live agent session on civiljobs.co.uk 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

Search CivilJobs for a departmental reference using the site's direct query-parameter filter and return matching vacancy links and titles.

When to Use

Use when the caller provides a CivilJobs departmental reference such as {reference} and needs to determine whether it identifies a vacancy, optionally checking its title.

Workflow

  1. Navigate directly to https://civiljobs.co.uk/?q={url-encoded-reference}. The q parameter initializes the same client-side filtering performed by the homepage search field; do not visit the homepage or type into the field separately.
  2. Wait approximately 2.2 seconds for the client-side vacancy filtering to finish.
  3. Run this evaluator on the loaded page, substituting the caller's values for {reference} and the optional {title-pattern} (a case-insensitive regular expression such as team leader; leave it empty to skip title filtering):
(() => {
  const reference = "{reference}";
  const titlePattern = "{title-pattern}";
  const matches = [...new Set(
    [...document.querySelectorAll('a[href*="/jobs/"]')]
      .map(a => ({
        href: new URL(a.getAttribute('href'), location.origin).href,
        title: a.textContent.replace(/\s+/g, ' ').trim()
      }))
      .filter(x => /\/jobs\/.*ref-\d+/i.test(x.href))
      .filter(x => (x.href + " " + x.title).toLowerCase().includes(reference.toLowerCase()))
  )];
  return {
    reference,
    found: matches.length > 0,
    matches,
    titleMatches: titlePattern ? matches.filter(x => new RegExp(titlePattern, "i").test(x.title)) : matches
  };
})()

Site-Specific Gotchas

  • CivilJobs filtering is client-side, but https://civiljobs.co.uk/?q={reference} directly reaches the filtered state and avoids homepage interaction.
  • URL-encode the reference when constructing the q parameter.
  • Wait for the dynamic filter to update before extracting results.
  • The search input, useful as a fallback if direct q initialization ever fails, is input#filter-search; setting its value must dispatch an input event.
  • Vacancy links use /jobs/ paths containing a ref-{digits} segment. Restrict extraction to those links rather than treating every /jobs/ link as a result.

Expected Output

An object of the form {reference, found, matches, titleMatches}, where each match contains its absolute href and visible vacancy title. found is true only when at least one vacancy link or title contains {reference}, so a failed ?q= filter cannot report a false positive; titleMatches narrows matches to titles matching {title-pattern} when one was supplied, otherwise it equals matches.

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=civiljobs.co.uk&task=search-jobs-by-departmental-reference