GD Shortener’s classes

Here you will found documentation on operations implemented by this module.

class gdshortener.ISGDShortener(timeout=60, user_agent='Mozilla/5.0 (compatible; GD Shortener Python Module - https://github.com/torre76/gd_shortener/)')

Shortener for is.gd url shortener.

Parameters:
  • timeout (int.) – Timeout in seconds used to connect and obtain shortened URL from .gd service
  • user_agent (str.) – User Agent used when querying .gd services
lookup(short_url)

Lookup an URL shortened with is.gd - v.gd url service and return the real url

Parameters:

short_url (str.) – the url shortened with .gd service

Returns:

str. – The original url that was shortened with .gd service

Raises :

IOError when timeout with .gd service occurs

ValueError if .gd response is malformed

gdshortener.GDMalformedURLError if the previously shortened URL provided is malformed

gdshortener.GDShortURLError if the custom URL requested is not available or disabled by .gd service

gdshortener.GDRateLimitError if the request rate is exceeded for .gd service

gdshortener.GDGenericError in case of generic error from .gd service (mainteinance)

shorten(url, custom_url=None, log_stat=False)

Shorten an URL using is.gd - v.gd url shortener service.

Parameters:
  • url (str.) – URL that had to be shortened
  • custom_url (str.) –

    if specified, the url generated will be http://is.gd/<custom_url> (or http://v.gd/<custom_url>).

    Please note that if this custom url is unavailable (because it is already used, for example), a gdshortener.GDShortURLError will be raised

  • log_stat (bool.) –

    States if the generated url has statistical analisys attached. If the stats are enabled, a special url will show the stats on this shortened url. This special url is returned as second parameters of this function.

    Please notice that a stat enabled shorten url counts double in .gd rate exceeding monitor system.

    More information on .gd FAQ and .gd rate limit.

Returns:

(str,str) – Shortened URL obtained by .gd service and Stat URL if requested (otherwhise is None).

Raises :

IOError when timeout with .gd service occurs

ValueError if .gd response is malformed

gdshortener.GDMalformedURLError if the URL provided for shortening is malformed

gdshortener.GDShortURLError if the custom URL requested is not available

gdshortener.GDRateLimitError if the request rate is exceeded for .gd service

gdshortener.GDGenericError in case of generic error from .gd service (mainteinance)

class gdshortener.VGDShortener(timeout=60, user_agent='Mozilla/5.0 (compatible; GD Shortener Python Module - https://github.com/torre76/gd_shortener/)')

Shortener for v.gd url shortener.

Parameters:
  • timeout (int.) – Timeout in seconds used to connect and obtain shortened URL from .gd service
  • user_agent (str.) – User Agent used when querying .gd services
lookup(short_url)

Lookup an URL shortened with is.gd - v.gd url service and return the real url

Parameters:

short_url (str.) – the url shortened with .gd service

Returns:

str. – The original url that was shortened with .gd service

Raises :

IOError when timeout with .gd service occurs

ValueError if .gd response is malformed

gdshortener.GDMalformedURLError if the previously shortened URL provided is malformed

gdshortener.GDShortURLError if the custom URL requested is not available or disabled by .gd service

gdshortener.GDRateLimitError if the request rate is exceeded for .gd service

gdshortener.GDGenericError in case of generic error from .gd service (mainteinance)

shorten(url, custom_url=None, log_stat=False)

Shorten an URL using is.gd - v.gd url shortener service.

Parameters:
  • url (str.) – URL that had to be shortened
  • custom_url (str.) –

    if specified, the url generated will be http://is.gd/<custom_url> (or http://v.gd/<custom_url>).

    Please note that if this custom url is unavailable (because it is already used, for example), a gdshortener.GDShortURLError will be raised

  • log_stat (bool.) –

    States if the generated url has statistical analisys attached. If the stats are enabled, a special url will show the stats on this shortened url. This special url is returned as second parameters of this function.

    Please notice that a stat enabled shorten url counts double in .gd rate exceeding monitor system.

    More information on .gd FAQ and .gd rate limit.

Returns:

(str,str) – Shortened URL obtained by .gd service and Stat URL if requested (otherwhise is None).

Raises :

IOError when timeout with .gd service occurs

ValueError if .gd response is malformed

gdshortener.GDMalformedURLError if the URL provided for shortening is malformed

gdshortener.GDShortURLError if the custom URL requested is not available

gdshortener.GDRateLimitError if the request rate is exceeded for .gd service

gdshortener.GDGenericError in case of generic error from .gd service (mainteinance)

Previous topic

GD Shortener

Next topic

GD Shortener’s Exceptions

This Page