2017 © Pedro Peláez
 

library netscape-bookmark-parser

Generic Netscape bookmark parser

image

kafene/netscape-bookmark-parser

Generic Netscape bookmark parser

  • Wednesday, August 2, 2017
  • by Kafene
  • Repository
  • 2 Watchers
  • 19 Stars
  • 43 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

netscape-bookmark-parser

license, (*1)

, (*2)

About

This library provides a generic NetscapeBookmarkParser class that is able of parsing Netscape bookmark export files., (*3)

The motivations behind developing this parser are the following: - the Netscape format has a very loose specification: no DTD nor XSL stylesheet to constrain how data is formatted - software and web services export bookmarks using a wild variety of attribute names and values - using standard SAX or DOM parsers is thus not straightforward., (*4)

How it works: - the input bookmark file is trimmed and sanitized to improve parsing results - the resulting data is then parsed using PCRE patterns to match attributes and values corresponding to the most likely: - attribute names: description vs. note, tags vs. labels, date vs. time, etc. - data formats: comma,separated,tags vs. space separated labels, UNIX epochs vs. human-readable dates, newlines & carriage returns, etc. - an associative array containing all successfully parsed links with their attributes is returned, (*5)

Example

Script:, (*6)

<?php
require_once 'NetscapeBookmarkParser.php';

$parser = new NetscapeBookmarkParser();
$bookmarks = $parser->parseFile('./tests/input/netscape_basic.htm');
var_dump($bookmarks);

Output:, (*7)

array(2) {
  [0] =>
  array(6) {
    'tags' =>
    string(14) "private secret"
    'uri' =>
    string(19) "https://private.tld"
    'title' =>
    string(12) "Secret stuff"
    'note' =>
    string(52) "Super-secret stuff you're not supposed to know about"
    'time' =>
    int(971175336)
    'pub' =>
    int(0)
  }
  [1] =>
  array(6) {
    'tags' =>
    string(18) "public hello world"
    'uri' =>
    string(17) "http://public.tld"
    'title' =>
    string(12) "Public stuff"
    'note' =>
    string(0) ""
    'time' =>
    int(1456433748)
    'pub' =>
    int(1)
  }
}

The Versions

02/08 2017

dev-master

9999999-dev https://github.com/kafene/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

  • php >=5.3.4

 

The Development Requires

link parse bookmark netscape

18/09 2015

v0.0.1

0.0.1.0 https://github.com/kafene/BookmarkParser

Parse Netscape format bookmark files

  Sources   Download

MIT

parse bookmark netscape