承接 kafene/netscape-bookmark-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kafene/netscape-bookmark-parser

最新稳定版本:v0.0.1

Composer 安装命令:

composer require kafene/netscape-bookmark-parser

包简介

Generic Netscape bookmark parser

README 文档

README

license

About

This library provides a generic NetscapeBookmarkParser class that is able of parsing Netscape bookmark export files.

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.

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

Example

Script:

<?php
require_once 'NetscapeBookmarkParser.php';

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

Output:

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)
  }
}

统计信息

  • 总下载量: 406
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 43
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 43
  • Watchers: 4
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-17