Building a Robot for the future
Is there a God?
Britain in the past
Reality is there if you agree or not!
Why its time to get off the property ladder
How do you think?
Wage Slave – its not a smart soundbite, its actually true
Theory of the age of civilisation
Powershell – changing parameters at the file name
How to view a government petition breakdown using Powershell

How to view a government petition breakdown using Powershell

In the UK we have a petition system where anyone can set up a petition and if it reaches 100K names, the subject gets debated in Parliament. Its an idea that gets misused by various lobby groups and there are often news stories where some political idea gets forced into debate by a group who can’t accept the status quo.

Anyway, enough politics, the interesting part is getting to the numbers.  Take the last big petition – all about Brexit. Each petition has a JSON page where all those lovely numbers are easy to see – but while JSON is easier to read than XML, its no Infographic!

https://petition.parliament.uk/petitions/131215.json

So how are we going to read this? Powershell!

Its only two lines, but its very good.

$datapetition = Invoke-WebRequest -uri “https://petition.parliament.uk/petitions/131215.json” | ConvertFrom-Json
$datapetition.data.attributes.signatures_by_constituency

The first line reads the data, and after the pipe, the variable becomes a Powershell object. The second line grabs the attribute we need. All you need to do is to read it.

$datapetition.data.attributes – this is where the magic is!

Unlike other site that will spoon feed you, I am not adding any more – just experiment and see all the data show up!

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *