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.3.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file aiourlshortener-0.0.3.tar.gz
.
File metadata
- Download URL: aiourlshortener-0.0.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f135cd251c5dfcd38bab474d265951b05d5a9b7ff20e5b9f549110c64be854 |
|
MD5 | 2f2295986e33089808e28c4edcf0ab74 |
|
BLAKE2b-256 | bbaabdb2776f410d5b9f75b86f05b474dac343c389d96c6b592796c469f49ba8 |
File details
Details for the file aiourlshortener-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: aiourlshortener-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc7bac0e8276c689e74c778bd976def3f1b9a9098580fcae040885b0d31acb0 |
|
MD5 | 8c309645dc50b1cd69fc1406986f1e62 |
|
BLAKE2b-256 | 2af7cdfea09757eb78ee3ac9fc7bf33444df2a0284c1c340a79253935def33cb |