This small script can help you to make your long links short and pretty using Bit.ly service, and it can check click statistics for your short links as well. This could be useful for SMM managers, for example.
- To use this script you have been registered on bit.ly service.
- After registration you should go to Your Account - Edit Profile - Generic Access Token and generate your private OAuth token.
- Create a file with name
.env
in the same folder as this script is, and put there the next text (place your bit.ly token instead your_token, with no quotes):
TOKEN=your_token
- Python should be already installed. The minimum requirement is Python 3.6.
- Use
pip
(orpip3
, if there is a conflict with Python2) to install dependencies:
pip install -r requirements.txt
Just start the python script with your link as argument:
$ python main.py http://dvmn.org
This is your very short link: http://bit.ly/2Myn2fj
$ python3.6 main.py http://bit.ly/2Myn2fj
This link has been clicked 3 times.
The code is written for educational purposes on online-course for web-developers dvmn.org.