Giter VIP home page Giter VIP logo

extractcontent's Introduction

ExtractContent for PHP

About ExtractContent

The ExtractContent will extract content from HTML.
It has been rewritten in PHP from Ruby and Perl.

Syuyo Nakatani:: http://labs.cybozu.co.jp/blog/nakatani/downloads/extractcontent.rb
Ina Lintaro:: http://search.cpan.org/dist/HTML-ExtractContent/lib/HTML/ExtractContent.pm

Getting Started

Clone the repo, git clone git://github.com/aoiaoi/ExtractContent.git: , or download the latest release.

Performing Basic Usage

Example #1 Instantiating a ExtractContent object

<?php
require_once 'ExtractContent.php';

$extractor = new ExtractContent();

Example #2 Extract content from HTML

$extractor = new ExtractContent();
$extractor->extract($html);
echo $extractor->asText();
// if retrieve as HTML:
echo $extractor->asHtml();

Example #3 Extract title from HTML

$extractor = new ExtractContent();
$extractor->extract($html);
echo $extractor->getTitle();

Example #4 Set parameters

$extractor = new ExtractContent(array('g_adsense' => true));

// This is actually exactly the same:
$extractor = new ExtractContent();
$extractor->setOptions('g_adsense' => true);

Configuration Parameters

threshold | integer 60
min_length | integer 30
decay_factor | integer 0.75
no_body_factor | integer 0.72
continuous_factor | integer 1.62
punctuation_weight | integer 10
min_nolink | integer 8
nolist_ratio | integer 0.2
g_adsense | boolean false
debug | boolian false

Available Public Methods

ExtractContent::setOptions(array $options);
ExtractContent::extract(string $html);
ExtractContent::getTitle();
ExtractContent::asText();
ExtractContent::asHtml();

Development Environment

PHP 5.4.1-rc2

Copyright

Copyright (c) 2012 aoiaoi. All rights reserved.

Copyright of the original implementation

Copyright (c) 2007-2012 Nakatani Shuyo / Cybozu Labs Inc. All rights reserved.

License

The files in this archive are released under the New BSD license. You can find a copy of this license in LICENSE.txt

extractcontent's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.