March 25, 2010
Who Am I Blocking on Twitter?

I have been curious to see a list of people I have blocked on Twitter.

Turns out there’s an easy way to do this:

curl -s --netrc http://twitter.com/blocks/blocking.xml |\
fgrep -B2 '<screen_name>' |\
tr '\012' ' ' |\
sed 's#<id>#\
#g' |\
sed 's#</id>.*<name>#   #g; s#</name>.*<screen_name>#   #g; s#</screen_name>.*# #g;'

It will give you a format like this:

15517541    buddiedaya44    buddiedaya44
15774186    Beth Varela ladylatasia

Where the first column is the Twitter ID and the last is their Twitter name. The middle is their “Real Name” (or their Twitter name again, if they have not entered a “Real Name”).

Note:

Your Twitter username and password must be in a plain text file ~/.netrc in order for this to work. The format of the file should look like this:

machine twitter.com
    login NAME
    password SEKRIT

where NAME is your Twittername (without the @) and SEKRIT is your actual password. You can put it all on one line:

machine twitter.com login NAME password SEKRIT

I just prefer the original formatting as it is easier to read.

Be sure to also do “chmod 600 ~/.netrc” so no one else can read the file.

You can also use curl like this

curl -s -u NAME:SEKRIT http://twitter.com/blocks/blocking.xml |\
fgrep -B2 '<screen_name>' |\
tr '\012' ' ' |\
sed 's#<id>#\
#g' |\
sed 's#</id>.*<name>#   #g; s#</name>.*<screen_name>#   #g; s#</screen_name>.*# #g;'

but that might reveal your Twitter username to other people who are logged onto the computer if they happen to run ‘ps’ at just the right time. Plus once it is in ~/.netrc you can reuse it for all the scripts and not have to keep typing it.

blog comments powered by Disqus