Skip to content

Instantly share code, notes, and snippets.

@scoates
Last active December 19, 2015 09:49
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scoates/5935435 to your computer and use it in GitHub Desktop.
Save scoates/5935435 to your computer and use it in GitHub Desktop.
Get a twitter profile image from a username. We route around bad APIs. Twitter wears the scumbag hat, these days.
#!/bin/bash
# Usage: $0 username
# e.g.:
# $ ./twitter_user_to_image coates
# https://si0.twimg.com/profile_images/1597362183/me.jpg
curl -sL http://twitter.com/$1 | grep profile_images | head -n1 | perl -p -e's/.*?http/http/;s/".*//;s/_bigger//'
@beryllium
Copy link

Suggestion that might come in handy in the future: Add a user agent. :)

--user-agent "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0"

Or choose one from this list: http://techblog.willshouse.com/2012/01/03/most-common-user-agents/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment