Casinelli / Laravel-Wikipedia by Casinelli

Laravel package to query Wikipedia
10,077
12
2
Package Data
Maintainer Username: Casinelli
Maintainer Contact: giovanni.casinelli@gmail.com (Casinelli)
Package Create Date: 2014-12-22
Package Last Update: 2021-06-24
Home Page:
Language: PHP
License: Unknown
Last Refreshed: 2024-12-24 03:00:38
Package Statistics
Total Downloads: 10,077
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 12
Total Watchers: 2
Total Forks: 11
Total Open Issues: 1

Wikipedia

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"];