Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.65 KB

python.md

File metadata and controls

61 lines (45 loc) · 1.65 KB

Python — Federal Register Scraper

Call the hosted Federal Register Scraper from Python using the official apify-client.

Install

pip install apify-client

Run and fetch results

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("logiover/federal-register-scraper").call(run_input={
    "query": "clean air",
    "agencies": ["environmental-protection-agency"],
    "types": ["RULE", "PRORULE"],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-12-31",
    "maxResults": 500,
})

items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(f"Got {len(items)} documents")
for x in items[:10]:
    print(x["publicationDate"], x["type"], x["title"])

Rules by agency with pandas

import pandas as pd
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("logiover/federal-register-scraper").call(run_input={
    "types": ["RULE"],
    "dateFrom": "2024-01-01",
    "maxResults": 5000,
})

df = pd.DataFrame(client.dataset(run["defaultDatasetId"]).list_items().items)
print(df["agencies"].value_counts().head(10))

Export official citations for a brief

citations = [f'{x["title"]} — {x["citation"]}' for x in items if x.get("citation")]
print("\n".join(citations))

Notes

  • Get your token from the Apify Console.
  • Every field is optional; empty input returns the most recent documents.
  • Full field reference: see the main README.