HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

How to Auto-Shorten URLs in a click of a button

953 views November 15, 2010 2:34

Watch on YouTube
ChannelMrNerdOTech

Description from the creator

Here's the script:

"""
author = Jurvis Tan
mail = [email protected]
"""

import json
import sys
import urllib2

login = 'automatorbitly'
apiKey = 'R_7d34d2586660c832cdf0fc736d773eb9'

longUrl = sys.argv[1]

url = """api.bit.ly/shorten?version=2.0.1&longUrl=%(…; %\
{ 'login' : login
, 'apiKey' : apiKey
, 'longUrl' : longUrl
}

try:

data = urllib2.urlopen(url).read()
data = json.loads(data)

print data['results'][longUrl]['shortUrl']

except Exception, e:
print longUrl

About this tutorial

MrNerdOTech published this 2:34 video tutorial on November 15, 2010. It has been watched 953 times on YouTube.

Duration
2:34
Published
November 15, 2010
Views
953

Tags

Share

This tutorial in other languages