Skip to main content

Link header parsing library for mementos

Project description

Link Parse

Python library for parsing memento link headers.

Installation

Installation of the library requires pip package installer for Python.

Install pip: https://pip.pypa.io/en/stable/installation/

1. Using Git

pip install https://github.com/mahanama94/link-parser

2. Local copy

pip install path/to/package/directory

Usage

# sample.py

from linkparse.regex_parser import RegexLinkParser
from pprint import pprint

link_header = '<http://www.mementoweb.org:80/>; rel="original", '\
'<https://web.archive.org/web/timemap/link/http://www.mementoweb.org:80/>; rel="timemap"; '\
'type="application/link-format", <https://web.archive.org/web/http://www.mementoweb.org:80/>; '\
'rel="timegate", <https://web.archive.org/web/20090930115825/http://www.mementoweb.org/>; rel="first '\
'memento"; datetime="Wed, 30 Sep 2009 11:58:25 GMT" '

parser = RegexLinkParser()

parser_results = parser.parse(link_header)

for result in parser_results:
    pprint(result.__dict__)
$ python sample.py

{'datetime': '',
 'link_from': '',
 'link_type': '',
 'link_until': '',
 'relationship': 'original',
 'title': '',
 'uri': 'http://www.mementoweb.org:80/'}
{'datetime': '',
 'link_from': '',
 'link_type': 'application/link-format',
 'link_until': '',
 'relationship': 'timemap',
 'title': '',
 'uri': 'https://web.archive.org/web/timemap/link/http://www.mementoweb.org:80/'}
{'datetime': '',
 'link_from': '',
 'link_type': '',
 'link_until': '',
 'relationship': 'timegate',
 'title': '',
 'uri': 'https://web.archive.org/web/http://www.mementoweb.org:80/'}
{'datetime': 'Wed, 30 Sep 2009 11:58:25 GMT',
 'link_from': '',
 'link_type': '',
 'link_until': '',
 'relationship': 'first memento',
 'title': '',
 'uri': 'https://web.archive.org/web/20090930115825/http://www.mementoweb.org/'}

#LANL Identification

LANL C number: C21088

Copyright

© 2021. Triad National Security, LLC. All rights reserved. This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.

Project details


Download files

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

Source Distribution

linkparse-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file linkparse-1.0.0.tar.gz.

File metadata

  • Download URL: linkparse-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for linkparse-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d8332ae84c2a8e2a29e942bdaa4199cf291e82bfb33e418521bdeca378940319
MD5 d064cb9b21ae7afa42abb68e6b7b7613
BLAKE2b-256 d1ded8f9a050c897dcb1300149f2ead06a097f1aa9e9d422ab83081995f0720f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page