Skip to main content
Help improve PyPI by participating in a 5-minute user interface survey!

Python module that extracts links and their relations from a Link Header Field and returns them in a dict.

Project Description

https://travis-ci.org/victor-o-silva/python-links-from-link-header.svg?branch=master Code Health https://coveralls.io/repos/github/victor-o-silva/python-links-from-link-header/badge.svg?branch=master

This Python module contains only one function: extract.

It extracts links and their relations from a Link Header Field [1] and returns a dict where the keys are the relations and the values are the links themselves.

[1]https://www.w3.org/wiki/LinkHeader and http://www.rfc-editor.org/rfc/rfc5988.txt

Installation

pip install links-from-link-header

Usage

>>> import links_from_header

>>> header = '<https://api.github.com/user/repos?page=1>; rel="first", <https://api.github.com/user/repos?page=9>; rel="prev", <https://api.github.com/user/repos?page=11>; rel="next", <https://api.github.com/user/repos?page=50>; rel="last"'

>>> links_from_header.extract(header)
{
    'first': 'https://api.github.com/user/repos?page=1',
    'prev': 'https://api.github.com/user/repos?page=9',
    'next': 'https://api.github.com/user/repos?page=11',
    'last': 'https://api.github.com/user/repos?page=50',
}

Release history Release notifications

This version
History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
links-from-link-header-0.1.0.tar.gz (1.6 kB) Copy SHA256 hash SHA256 Source None Apr 16, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page