asynchronous python3 lib to short long url
Project description
# aiourlshortener
aiourlshortener is a [asyncio](https://pypi.python.org/pypi/asyncio) python3 compatible library for URL shorting using [Googl](https://goo.gl/), [Bitly](https://bitly.com/) API
# Installing
```
pip3 install aiourlshortener
```
# Requirements
* [asyncio](https://pypi.python.org/pypi/asyncio) or Python 3.4+
* [aiohttp](https://pypi.python.org/pypi/aiohttp)
# Usage
Create a Shortener instance passing the engine as an argument.
## Goo.gl Shortener
`api_key` required
```python
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
```python
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())
```
aiourlshortener is a [asyncio](https://pypi.python.org/pypi/asyncio) python3 compatible library for URL shorting using [Googl](https://goo.gl/), [Bitly](https://bitly.com/) API
# Installing
```
pip3 install aiourlshortener
```
# Requirements
* [asyncio](https://pypi.python.org/pypi/asyncio) or Python 3.4+
* [aiohttp](https://pypi.python.org/pypi/aiohttp)
# Usage
Create a Shortener instance passing the engine as an argument.
## Goo.gl Shortener
`api_key` required
```python
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
```python
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())
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiourlshortener-0.0.2.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for aiourlshortener-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32144e06c16b3fb4059612844d1af646f754e8867b3595caf5b48b919dc7555e |
|
MD5 | 1cd2cd855bfd7c1391f45d970645647a |
|
BLAKE2b-256 | 3ae4957bcd5e20e1dc94d672d5b19889c7057d5d3536d2254577b2551318bb49 |