Prompt

How can I scrape public government websites?

Latest observation

Jul 15, 2026 · OpenAI APIWeb search: off

To scrape public government websites safely and legally, use a respectful, rate-limited approach and follow each site’s terms.

Best practices

  1. Check the site’s rules

    • Read the site’s Terms of Service.
    • Check robots.txt for crawl restrictions.
    • Look for an official API or downloadable data portal first.
  2. Use polite scraping

    • Send a clear User-Agent string identifying your app and contact info.
    • Keep request rates low.
    • Add delays between requests.
    • Avoid parallel bursts unless explicitly allowed.
  3. Only collect public data

    • Don’t try to bypass logins, CAPTCHAs, paywalls, or access controls.
    • Avoid collecting personal or sensitive data unless you have a lawful basis.
  4. Handle the server responsibly

    • Cache results so you don’t re-download the same pages.
    • Respect HTTP headers like ETag and Last-Modified.
    • Retry carefully with backoff on failures.
  5. Be prepared for changing pages

    • Government sites often change markup.
    • Use robust selectors and validation checks.

Example in Python

import requests
from bs4 import BeautifulSoup
import time

url = "https://example.gov/data"
headers = {
    "User-Agent": "MyResearchBot/1.0 (contact: you@example.com)"
}

resp = requests.get(url, headers=headers, timeout=30)
resp.raise_for_status()

soup = BeautifulSoup(resp.text, "html.parser")
for link in soup.select("a"):
    print(link.get_text(strip=True), link.get("href"))

time.sleep(2)  # be polite before next request

If you need lots of data

  • Prefer bulk downloads, RSS feeds, or APIs.
  • If none exist, contact the site owner or webmaster and ask for permission or a data feed.

Avoid

  • Scraping aggressively.
  • Ignoring robots/TOS.
  • Circumventing protections.
  • Republishing data that has licensing restrictions without checking rights.

If you want, I can help you build a scraper for a specific government site in Python or JavaScript.

Observation history

Unlock observation history

Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.