pyshorteners package¶
-
class
pyshorteners.
Shortener
(**kwargs)¶ Bases:
object
Base Factory class to create shoreteners instances
>>> s = Shortener(**kwargs) >>> instance = s.shortener_name >>> instance.short('http://www.google.com') 'http://short.url/'
Available Shorteners can be seen with:
>>> s = Shortener() >>> print(s.available_shorteners)
Subpackages¶
- pyshorteners.shorteners package
- Submodules
- pyshorteners.shorteners.adfly module
- pyshorteners.shorteners.bitly module
- pyshorteners.shorteners.chilpit module
- pyshorteners.shorteners.clckru module
- pyshorteners.shorteners.cuttly module
- pyshorteners.shorteners.dagd module
- pyshorteners.shorteners.gitio module
- pyshorteners.shorteners.isgd module
- pyshorteners.shorteners.nullpointer module
- pyshorteners.shorteners.osdb module
- pyshorteners.shorteners.owly module
- pyshorteners.shorteners.post module
- pyshorteners.shorteners.qpsru module
- pyshorteners.shorteners.shortcm module
- pyshorteners.shorteners.tinycc module
- pyshorteners.shorteners.tinyurl module
Submodules¶
pyshorteners.base module¶
-
class
pyshorteners.base.
BaseShortener
(**kwargs)¶ Bases:
object
Base Class for all shorteners.
- Keyword Arguments
proxies (dict, optional) – Web proxy configuration for Requests Proxies.
timeout (int, optional) – Seconds before request is killed.
verify (bool, str, optional) – SSL Certificate verification for Requests Verification.
Example
>>> class NewShortener(BaseShortener): ... api_url = 'http://the/link/for/the/api' ... def short(self, url): ... pass ... def expand(self, url): ... pass ... def custom_method(self): ... pass
-
static
clean_url
(url)¶ URL validation.
- Parameters
url (str) – URL to shorten.
- Raises
BadURLException – URL is not valid.
-
expand
(url)¶ Expand URL using a shortening service.
Only visits the link, and returns the response url.
- Parameters
url (str) – URL to shorten.
- Raises
ExpandingErrorException – URL failed to expand.
-
short
(url)¶ Shorten URL using a shortening service.
- Parameters
url (str) – URL to shorten.
- Raises
NotImplementedError – Subclass must override.
pyshorteners.exceptions module¶
-
exception
pyshorteners.exceptions.
BadAPIResponseException
(message)¶ Bases:
Exception
-
exception
pyshorteners.exceptions.
BadURLException
(message)¶ Bases:
Exception
-
exception
pyshorteners.exceptions.
ExpandingErrorException
(message=None)¶ Bases:
Exception
-
exception
pyshorteners.exceptions.
ShorteningErrorException
(message=None)¶ Bases:
Exception