GitHub URL Shortener¶
Medium Article Link: http://medium.com/p/f1e0aeaf83b6¶
Shorten URL using curl¶
To create shortened URL¶
curl -i https://git.io -F "url=GITHUB_URL"
To create shortened URL with custom text¶
curl -i https://git.io -F "url=GITHUB_URL" -F "code=CUSTOM_TEXT"
To retrieve full URL¶
curl -i https://git.io/SHORTENED-URL
Shorten URL using Python¶
To create shortened URL¶
import requests
url = 'https://git.io/'
data = {'url': GITHUB-URL,
'code': CUSTOM-TEXT}
r = requests.post(url, data=data)
print(r.headers.get('Location'))
To retrieve full URL¶
import requests
r = requests.head('https://git.io/SHORTENED-URL')
print(r.headers.get('Location'))