twitterのような140文字制限のある文章内にURLを入れたいときには、短縮URLを使うのが常識だ python使ってbit.lyの短縮URLを取得するスクリプトを書いてみた。 json形式とXML形式での取得が可能のようだが、今回はJSONを処理することにする。 # coding: utf-8 from urllib2 import urlopen from urllib import urlencode import simplejson as json class bitly(): def __init__(self,login_id,api_key): self.login_id = login_id self.api_key = api_key self.dec = json.JSONDecoder() def shorten(self,url): param = { 've