Untiny your URLs from Command Line with Python Script

Firstly if you don’t know what is untiny watch this video

and Now Untiny the shorten URLs from command line in Linux ( from the terminal).

here is a python script to untiny shorten URLs using untiny API which is available under this service Untiny.me

here the script (you can download it and use it in your system to insure that there is no viruses or malicious software under this link

#!/usr/bin/env python

import sys

import urllib

import urllib2

from optparse import OptionParser

def main():

parser = OptionParser(usage=”usage: %prog [options] Short URL”,

version=”%prog 1.0″)

parser.add_option(“-u”, “–url”,

action=”store_true”,

dest=”url”,

default=False,

help=”Enter the shorten URL here”)

(options, args) = parser.parse_args()

if len(args) != 1:

parser.error(“wrong number of arguments”)

data = {}

data['url']=sys.argv[2]

data['format']=’text’

url_parameters = urllib.urlencode(data)

base_url=’http://untiny.me/api/1.0/extract/’

full_url = base_url + ‘?’ + url_parameters

data = urllib2.urlopen(full_url)

get_orgn_url = data.read()

print get_orgn_url

if __name__ == ‘__main__’:

main()

how to run the script

firstly give the script execute permission :

chomd +x LongURL.py

then run the script with shorten URL for example (http://tiny.cc/33s57)

./LongURL.py -u http://tiny.cc/33s57

the output will the Long URL in our  example (http://www.youtube.com/)

to get help on how to use the script use this :

./LongURL.py -h

Output:

Usage: LongURL.py [options] Short URL

Options:

–version   show program’s version number and exit

-h, –help  show this help message and exit

-u, –url   Enter the shorten URL here

Download here

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.