aiourlshortener is a asyncio python3 compatible library for URL shorting using Googl, Bitly API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
aiourlshortener
.gitignore
.pypirc
LICENSE.txt
README.md
README.rst
setup.cfg
setup.py

README.md

aiourlshortener

aiourlshortener is a asyncio python3 compatible library for URL shorting using Googl, Bitly API

Installing

pip3 install aiourlshortener

Requirements

Usage

Create a Shortener instance passing the engine as an argument.

Goo.gl Shortener

api_key required

import asyncio
from asyncio import coroutine
from aiourlshortener import Shortener

@coroutine
def main():
    shortener = Shortener('Google', api_key='API_KEY')
    url = 'https://github.com/blikenoother/aiourlshortener'
    # short
    short_url = yield from shortener.short(url)
    print('short url: {}'.format(short_url))
    # expand
    long_url = yield from shortener.expand(short_url)
    print('long url: {}'.format(long_url))

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Bit.ly Shortener

access_token required

import asyncio
from asyncio import coroutine
from aiourlshortener import Shortener

@coroutine
def main():
    shortener = Shortener('Bitly', access_token='ACCESS_TOKEN')
    url = 'https://github.com/blikenoother/aiourlshortener'
    # short
    short_url = yield from shortener.short(url)
    print('short url: {}'.format(short_url))
    # expand
    long_url = yield from shortener.expand(short_url)
    print('long url: {}'.format(long_url))

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())