Skip to content

Instantly share code, notes, and snippets.

@bilbof
Last active December 30, 2019 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilbof/dc41df6dd783668fcf2692c9ac44b917 to your computer and use it in GitHub Desktop.
Save bilbof/dc41df6dd783668fcf2692c9ac44b917 to your computer and use it in GitHub Desktop.
# this script fetches the content items for finders (search UIs) on GOV.UK
require 'httparty'
def request(url)
JSON.parse(HTTParty.get(url).body)
end
def finders_urls
finders = request('https://www.gov.uk/api/search.json?filter_content_store_document_type=finder&count=100&fields=link').dig('results')
finders.map { |finder| finder['link'] }
end
def all_finders
finders_urls.map { |url| request('https://gov.uk/api/content' + url) }
end
all = all_finders
all.find { |finder| finder.dig('details', 'nation_applicability') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment