# HSENI Publications Metadata Scraper (`vixendata/hseni-publications-metadata-scraper`) Actor

Northern Ireland official publication metadata, source dates, topics and document links. Bounded recent discovery; documents never downloaded.

- **URL**: https://apify.com/vixendata/hseni-publications-metadata-scraper.md
- **Developed by:** [Vixendata](https://apify.com/vixendata) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 recognized consultation/publication/alert metadata records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## HSENI Publications Metadata Scraper

Export official Northern Ireland safety publication metadata into an Apify dataset for regulatory monitoring, research inventories and document-link feeds. HSENI is the Health and Safety Executive for Northern Ireland, a separate regulator from Great Britain's HSE.

### Scope

Reads only the first unfiltered https://www.hseni.gov.uk/publications catalog page and optional explicit publication detail URLs. Consultations are not supported. It does not paginate, filter via query strings, claim historical completeness, download documents, interpret legislation or score compliance. The catalog is a recent snapshot, not an exhaustive archive. Source metadata is observational, not legal advice.

At most 30 detail pages are inspected and 30 records emitted. Explicit URLs are prioritized, followed by first-page discovery. One canonical detail page yields one record, regardless of its document count. Filters do not expand discovery. Schedule repeated runs in Apify and compare canonical URLs downstream if monitoring is desired; this Actor does not persist change history.

### Input

Defaults: discoverPublications true, maxItems 10. sourceUrls accepts up to 30 plain HTTPS www.hseni.gov.uk/publications/slug URLs. sinceDate is an inclusive YYYY-MM-DD publication-date filter; undated records are excluded when filtering. topicKeywords matches any keyword as a case-insensitive substring in official topics. No custom host, query, consultation or document-fetch options are supported.

Example:

```json
{"discoverPublications":true,"maxItems":5,"sinceDate":"2026-01-01","topicKeywords":["Mining"]}
```

### Dataset

Each record contains source, contentType (publication), url, title, publishedDate (ISO date or null), topics, publicationType (null when absent), summary, documentLinks (title/url/type/sizeText), observedAt (UTC retrieval time), attribution and diagnostics. Documents are links only and never fetched. Some source fields can be null; diagnostics identify unrecognized or missing dates.

RUN_REPORT in the default key-value store records status, error, requests, checked, emitted, filtered, scope and documentsFetched. Source denials, robots prohibitions, redirects and layout errors stop the run and mark it failed; previously written rows may remain. Inspect this report before treating output as a complete run.

### Responsible access and reuse

The fixed HTTPS host and publication-only paths are enforced. robots.txt is checked before HTML fetches, including wildcard restrictions. Sequential requests have a minimum two-second delay and honor longer source crawl delays up to 60 seconds; larger delays stop. Request-rate directives stop conservatively for manual review. Invalid robots responses stop the run. Requests have 25-second timeouts and 2 MB limits. No retries, redirects, configurable scraper proxies, CAPTCHAs or alternative-host workarounds are used. Standard runtime network egress is used. Source robots prohibits document downloads and query/faceted URLs, so neither is fetched. Returned document URLs are references, not permission to crawl them.

Contains public sector information from the Health and Safety Executive for Northern Ireland licensed under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/), pursuant to the [HSENI Crown copyright notice](https://www.hseni.gov.uk/crown-copyright). Attribute HSENI and source URLs when reusing output. Third-party material, personal data, logos and maps are excluded from this reuse claim. No HSENI endorsement is implied. Assess intended downstream reuse independently.

### Run and test

Python 3.12: install requirements.txt and run `python main.py`, or build the included Apify Dockerfile. Configure input on Apify and export the default dataset in JSON/CSV.

`python -m unittest discover -s tests -v` runs portable tests against bundled original official publication HTML, catalog and robots snapshots collected 2026-10-05. Covers dates, discovery, URL guards (including excluded consultation paths), robots, denied access and actual Apify SDK fixture-positive and denied-source runs. The SDK test emits one record into temporary local storage without cloud charges. Fixture tests alone are not evidence of current live availability.

# Actor input Schema

## `sourceUrls` (type: `array`):

Optional plain HTTPS HSENI publication detail URLs. No queries, consultations, documents or other hosts.

## `discoverPublications` (type: `boolean`):

Read only the first unfiltered publication catalog page.

## `maxItems` (type: `integer`):

Maximum emitted records, with at most 30 detail pages inspected.

## `sinceDate` (type: `string`):

Optional YYYY-MM-DD inclusive client-side publication date filter. Missing dates excluded.

## `topicKeywords` (type: `array`):

Optional case-insensitive OR substring matches in official topics only; applied locally.

## Actor input object example

```json
{
  "sourceUrls": [],
  "discoverPublications": true,
  "maxItems": 10,
  "sinceDate": "",
  "topicKeywords": []
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("vixendata/hseni-publications-metadata-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("vixendata/hseni-publications-metadata-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call vixendata/hseni-publications-metadata-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vixendata/hseni-publications-metadata-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/XAF5yPjuoSBPhcJvL/builds/buuwNXaaDYDPR2iTx/openapi.json
