casinelli/wikipedia

There is no license information available for the latest version (dev-master) of this package.

Laravel package to query Wikipedia

dev-master 2018-04-04 15:09 UTC

This package is not auto-updated.

Last update: 2024-11-14 19:10:10 UTC


README

Installation

Begin by installing this package through Composer.

{
    "require": {
        "casinelli/wikipedia": "dev-master"
    }
}

Usage

Retrieve page extract

$wikipedia = new \Casinelli\Wikipedia\Wikipedia;

return $wikipedia->search("Rome")->getSentences(5);

Same with QueryBuilder

$qb = new \Casinelli\Wikipedia\QueryBuilder;

$qb->setFormat("php");
$qb->setTitles("Singapore");
$qb->setExtractsSentences(3);
$qb->setExtractsPlainText(true);

$response = unserialize( $qb->fetch() );

$page = reset( $response["query"]["pages"] );

return $page["extract"];