Giter Club home page Giter Club logo

count-bitly-links's Introduction

Bitly URL shortener

Console utility for shortening web links using bit.ly service and counting clicks on shortened links.

How to install

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

pip install -r requirements.txt

Before you start using the utility, you will need an access token. Here is how to set it up:

  1. If you haven't, download the ZIP archive of the script and unzip it.
  2. Go to the directory where main.py file is and create a file with the name .env (yes, it has only the extension). It is the file to contain environmental variables that usually store data unique to each user, thus you will need to create your own.
  3. Copy this string: ACCESS_TOKEN='{token}' and paste it to .env file.
  4. Sign up for bit.ly service (or log in to it, if you already had).
  5. Go to "API" section of "Settings" page.
  6. Enter your password and click Generate token button.
  7. Copy the token and substitute {token} portion of .env file with it. Token has to remain inside ' ' quotation marks and without { } curly brackets.
  8. That's it! Now the script will use your token to access bit.ly service in order to run script's functions.

How to use

  1. You can run this script in two modes:
    • Without arguments to use loop mode if you need to process more than one link.
      • python3 main.py
        
    • Or with URL as optional positional argument, like this:
      • python3 main.py -u URL
        
  2. Enter a long URL to create a bitlink (short URL made with bit.ly service).
  3. Or enter a bitlink URL to get a number of clicks done on it.
  4. If either of those URLs were wrong or contained a typo, the script will show an error message. Inspect the URL you had entered and try again.
  5. In loop mode you can enter as many URLs as you need. To exit the script, just press Enter without typing anything.

Usage example

With command line argument:

python3 main.py -u https://dvmn.org/encyclopedia
Bitlink: https://bit.ly/3tkfIKW

python3 main.py -u https://dvmn.org/encyclopedi
HTTP error: 404 Client Error: Not Found for url: https://dvmn.org/encyclopedi
It is possible that your link contains a typo.

python3 main.py -u https://bit.ly/3tkfIKW
Number of clicks: 2

python3 main.py -u https://bit.ly/3tkfIKWW
HTTP error: 404 Client Error: Not Found for url: https://bit.ly/3tkfIKWW
It is possible that your link contains a typo.

In loop mode:

Enter a link (or just press "Enter" to quit): https://dvmn.org/encyclopedia
Bitlink: https://bit.ly/3tkfIKW

Enter a link (or just press "Enter" to quit): https://dvmn.org/encyclopedi
HTTP error: 404 Client Error: Not Found for url: https://dvmn.org/encyclopedi
It is possible that your link contains a typo.

Enter a link (or just press "Enter" to quit): https://bit.ly/3tkfIKW
Number of clicks: 2

Enter a link (or just press "Enter" to quit): https://bit.ly/3tkfIKWW
HTTP error: 404 Client Error: Not Found for url: https://bit.ly/3tkfIKWW
It is possible that your link contains a typo.

Enter a link (or just press "Enter" to quit): 

Process finished with exit code 0

Project Goals

The code is written for educational purposes on the online-course for web-developers, dvmn.org.

count-bitly-links's People

Contributors

katsutami7moto avatar

Watchers

James Cloos avatar  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.