don't worry, it's probably fine

How many all-party parliamentary groups have twitter accounts?

07 Nov 2020

nablopomo civic tech
tl;dr: not many, about 30%

An all-party parliamentary group (APPG) in the UK is an association of Members of Parliament (MPs) and Lords who are interested in a particular topic.

This can be anything from the way government operates, to sports, to e-sports, to particular countries or religions.

I was curious how many of these groups had Twitter accounts after seeing a few on my feed being retweeted by MPs.

First - where’s the canonical list of APPGs?

Registered APPGs

The authoritative list of registered APPGs is published on the UK Parliament Website. This list gets updated approximately every month with additions of groups that have been newly or re-registered and removals of groups that are defunct or have chosen not to renew themselves.

This is a HTML page, so I wrote a bit of console Javascript and pulled out a list of JSON objects to start manipulating.

var data = [];

[...document.getElementsByTagName('li')]
    .map(el => 
        data.push({"name": el.textContent.trim(), "twitter":""})
    );

JSON.stringify(data);

This includes some section headers on the page, but is good enough - I just trimmed those out manually.

Next, how to check these APPGs against twitter?

Getting Twitter accounts

There’s no real easy way of doing this, just “elbow-grease” and a lot of searching.

It reached the point where I was asked to complete a captcha by Google, presumably because I kept repeating the query site:twitter.com appg <name>.

I don’t claim that the list I’ve compiled is 100% accurate, but it’s certainly the most that I could find.

The JSON file is on Github under mrwilson/appg-social-media. I also started trying to find APPGs on Facebook but there seem to be even fewer there.

At time of writing, there are 195 APPGs with a Twitter account that can be identified as belonging to them. I had to use judgement on some less active ones. It’s quite easy to pretend to be anyone else on Twitter.

Full credit to the account that claimed to be the “All-Party Parliamentary Group for Taylor Swift”, you almost had me for a moment.

Syncing it to a Twitter list

Now that I’ve got that data, I wanted to make use of it by publishing it as a followable Twitter list.

In pseudo-code

json := (load json from repository)
twitter := (load list from Twitter API)

for appg in json and not in twitter:
    add appg to twitter list

for appg in twitter and not in json:
    remove appg from twitter list

I used tweepy to write a script that synchronises the JSON in the repository with a public Twitter list.

This is run manually by me, I might set up something like a GitHub action to run it automatically on changes to the codebase.

Why?

I was curious. That’s genuinely the only reason.

And since I couldn’t find the answer online I decided to find out myself and publish the answer for anyone else who might find the data set interesting.


November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2020 - some short and sweet, others long and boring.