Skip to content

Instantly share code, notes, and snippets.

@mh0w
Created February 2, 2024 09:43
Show Gist options
  • Save mh0w/2f7a4985f9523a783588a0ad075bd842 to your computer and use it in GitHub Desktop.
Save mh0w/2f7a4985f9523a783588a0ad075bd842 to your computer and use it in GitHub Desktop.
Supress specific warning messages
import requests
import warnings
# Suppress warnings containing the text "Unverified HTTPS request"
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message="Unverified HTTPS request")
list_of_available_datasets = json.loads(
requests.get("https://api.beta.ons.gov.uk/v1/datasets", verify=False).text
)
# Suppress warnings of class type UserWarning
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment