Git Product home page Git Product logo

bitly-cli's Introduction

Bitly URL Shortener

A simple command line interface for Bitly written in Python. Shorten URLs or get click statistics for existing bitlinks (shortened links).

How to Install

Get a Bitly Token

You will need an API token to use Bitly via this script.

To obtain it, create an account on Bitly. I recommend signing up with email โ€” for some reason, getting an API token gets trickier if you create an account using social media.

Confirm your email and then go to Developer settings and generate an access token. It will be a string looking something like this: 17c09e20ad155405123ac1977542fecf00231da7.

Create a file named ".env" in the same directory as the script. This is where your API token will be (more or less safely) stored. Add the following line to the file: "BITLY_TOKEN=your_token" (remove the quotation marks). The file will look like this:

BITLY_TOKEN=17c09e20ad155405123ac1977542fecf00231da7

Install the Required Packages

Python3 should be already installed. Then use pip (or pip3, if there is a conflict with Python2) to install dependencies:

$ pip install -r requirements.txt

Optionally, you can use virtualenv to install the packages inside a virtual environment and not on your entire system. In this case you will need to configure running the script from the virtual environment as well.

Run the Script

Open the terminal and run:

$ python3 path/to/the/script/main.py https://long-link.that/you-want?to=shorten 

or to get statistics (total clicks) for an existing bitlink:

$ python3 path/to/the/script/main.py bit.ly/link-code 

Keep in mind that the script will not shorten links without the URL scheme supplied (http://, https://, etc).

References

bitly-cli's People

Contributors

mavel-x avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.