bangpound / tika-rest-client
Apache Tika 的 Web 服务客户端
1.0.0
2014-04-23 05:05 UTC
Requires
- php: >=5.3.0
- guzzle/guzzle: ~3.7.2
Requires (Dev)
- apache/tika: ~1.4
- monolog/monolog: 1.*
- phpunit/phpunit: 3.7.*
- psr/log: 1.0.*
This package is auto-updated.
Last update: 2024-09-12 03:48:47 UTC
README
此 PHP 客户端与Tika REST 服务器交互,用于从[各种文档文件类型][types]中提取内容和元数据。存在[替代 PHP 库][alternatives],它们使用Tika 命令行客户端,但每次操作实例化 JVM 都会很慢且成本高昂。
此客户端基于 Guzzle 构建。
"参见“将 Tika 用作命令行工具”"[types]: http://tika.apache.org/1.4/formats.html [alternatives]: https://packagist.org.cn/search/?q=tika
项目设置
此项目通过 composer 安装。
在 shell 中,您可以运行此命令
composer require bangpound/tika-rest-client
或者您可以将此需求包含在您的 composer.json
文件中
{ "require": { "bangpound/tika-rest-client": "^1.0" } }
使用方法
<?php $client = new Bangpound\Tika\Client('http://localhost:9998'); $response = $client->tika(array( 'file' => 'TestPDF.pdf', )); // Metadata varies by file and file type, so refer to the Apache Tika docs for details. $all_metadata = $response->metadata; // If you know the metadata element you want to retrieve, specify it as the argument // to the response's metadata method. $author = $response->metadata('author'); // Extracted content can be retrieved as a SimpleXMLElement or a string of XML. $content_xml = $response->getBody(); $page_2 = $content_xml->children()->div[1]; $content_text = $response->getBody(true);
测试
Tika REST 客户端有一套不完整的测试。在安装开发依赖项后使用 phpunit 运行它们。
composer install phpunit
许可证
此代码在 MIT 许可证下发布。