Last active
April 14, 2019 00:02
-
-
Save madhurgupta10/4a0fd0dac408cb4bbc0bd3eabe5f7525 to your computer and use it in GitHub Desktop.
Short Url using bitly with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shorturl(): | |
import requests | |
import json | |
link = input("Enter url: ") | |
query_params = {'access_token': 'your key goes here, use generic key only', | |
'longUrl': link} | |
endpoint = 'https://api-ssl.bitly.com/v3/shorten' | |
response = requests.get(endpoint, params=query_params, verify=False) | |
data = json.loads(response.content) | |
print(data['data']['url']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment