Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
365 B
2
Indexable
Never
import requests
import json

url_to_shorten = "https://w.amazon.com/index.php/User:Pfusu"
api_endpoint = "http://tiny.amazon.com/submit/url"

headers = {"Accept": "application/json"}
payload = {"name": url_to_shorten}

response = requests.post(api_endpoint, headers=headers, data=payload)
shortened_url = json.loads(response.text)['short_url']

print(shortened_url)
Leave a Comment