How to scrape O
NS
with AgentQL

Looking for a better way to scrape ONS? Say goodbye to fragile XPath or DOM selectors that easily break with website updates. AI-powered AgentQL ensures consistent web scraping across various platforms, from ONS to any other website, regardless of UI changes.

Not just for scraping ONS

Smart selectors work anywhere

https://ons.gov.uk

URL

Input any webpage.

{
  news_articles[] {
    headline
    date
    summary
  }
}

Query

Describe data in natural language.

{
  "news_articles": [
    {
      "headline": "UK inflation rate falls to 8.7%",
      "date": "2024-05-16",
      "summary": "The UK's inflation rate has fallen to 8.7% in April, down from 10.1% in March."
    },
    {
      "headline": "Unemployment rate remains low at 3.8%",
      "date": "2024-05-10",
      "summary": "The UK's unemployment rate remains low at 3.8%, suggesting a strong labour market."
    },
    {
      "headline": "New measures announced to boost economy",
      "date": "2024-05-03",
      "summary": "The government has unveiled a package of measures to stimulate the UK economy."
    }
  ]
}

Returns

Receive accurate output in seconds.

How to use AgentQL on ONS

A dotted lineA blue lineA blue line
1

Install the SDK

Install code for JS and Python

npm install agentql

pip3 install agentql

2

Test and refine

Use the query debugger

3

Run your script

Install code for both JS and Python

agentql init

python example.py

Get started

Holds no opinions on what’s and how’s. Build whatever makes sense to you.