https://github.com/dmitry-ivanov/laravel-wikipedia-grabber
Wikipedia/MediaWiki Grabber for Laravel.
https://github.com/dmitry-ivanov/laravel-wikipedia-grabber
grabber laravel laravel-package mediawiki parser wiki wikipedia wikipedia-grabber wikipedia-parser
Last synced: 15 days ago
JSON representation
Wikipedia/MediaWiki Grabber for Laravel.
- Host: GitHub
- URL: https://github.com/dmitry-ivanov/laravel-wikipedia-grabber
- Owner: dmitry-ivanov
- License: mit
- Created: 2018-01-18T15:11:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T16:14:42.000Z (about 2 months ago)
- Last Synced: 2025-04-01T21:11:41.840Z (23 days ago)
- Topics: grabber, laravel, laravel-package, mediawiki, parser, wiki, wikipedia, wikipedia-grabber, wikipedia-parser
- Language: HTML
- Homepage:
- Size: 6.31 MB
- Stars: 48
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

# Laravel Wikipedia Grabber
[
](https://buymeacoffee.com/dmitry.ivanov)
[](https://github.styleci.io/repos/117998599?branch=master)
[](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/actions?query=workflow%3Atests+branch%3Amaster)
[](https://app.codecov.io/gh/dmitry-ivanov/laravel-wikipedia-grabber/tree/master)


Wikipedia/MediaWiki Grabber for Laravel.
| Laravel | Wikipedia Grabber |
|---------|------------------------------------------------------------------------------|
| 12.x | [12.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/12.x) |
| 11.x | [11.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/11.x) |
| 10.x | [10.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/10.x) |
| 9.x | [9.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/9.x) |
| 8.x | [8.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/8.x) |
| 7.x | [7.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/7.x) |
| 6.x | [6.x](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/6.x) |
| 5.8.* | [5.8.*](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/5.8) |
| 5.7.* | [5.7.*](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/5.7) |
| 5.6.* | [5.6.*](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/5.6) |
| 5.5.* | [5.5.*](https://github.com/dmitry-ivanov/laravel-wikipedia-grabber/tree/5.5) |
## Table of contents
- [Usage](#usage)
- [Output formats](#output-formats)
- [Available methods](#available-methods)
- [Advanced](#advanced)
- [MediaWiki](#mediawiki)
- [Modify the grabbed page](#modify-the-grabbed-page)
- [Sponsors](#sponsors)
- [License](#license)## Usage
1. Install the package via Composer:
```shell script
composer require illuminated/wikipedia-grabber
```2. Publish the config:
```shell script
php artisan vendor:publish --provider="Illuminated\Wikipedia\WikipediaGrabberServiceProvider"
```3. Grab a full page or preview:
```php
use Wikipedia;echo (new Wikipedia)->page('Michael Jackson');
echo (new Wikipedia)->preview('Michael Jackson');// Or
echo (new Wikipedia)->randomPage();
echo (new Wikipedia)->randomPreview();
```## Output formats
Here's the list of supported output formats:
- `plain` (default)
- `bootstrap`
- `bulma`Change the format in your config file, or specify it explicitly:
```php
echo (new Wikipedia)->page('Michael Jackson')->bulma();
```## Available methods
When you call the `page()` or `preview()` method, you'll get an instance of the proper object.
There are numerous methods available on these objects, for example:
```php
$page = (new Wikipedia)->page('Michael Jackson');$page->isSuccess(); // true
$page->isMissing(); // false
$page->isInvalid(); // false
$page->isDisambiguation(); // falseecho $page->getId(); // 14995351
echo $page->getTitle(); // "Michael Jackson"
echo $page->getBody(); // Same as `echo $page;`
```## Advanced
### MediaWiki
Wikipedia uses the [MediaWiki API](https://mediawiki.org/wiki/API:Main_page) under the hood.
Thus, you can grab pages from any MediaWiki website:
```php
use MediaWiki;echo (new MediaWiki($url))->page('Michael Jackson');
```### Modify the grabbed page
Sometimes it might be useful to append additional sections to the grabbed page:
```php
$page = (new Wikipedia)->page('Michael Jackson');$page->append('Interesting Facts', 'He had two pet llamas on his ranch called Lola and Louis.');
```Alternatively, you can get the sections collection and change it as needed:
```php
$page = (new Wikipedia)->page('Michael Jackson');$sections = $page->getSections();
$sections->push(
new Section('Interesting Facts', 'He had two pet llamas on his ranch called Lola and Louis.', $level = 2)
);
```## Sponsors
[](https://laravel-idea.com)
[](https://material-theme.com)## License
Laravel Wikipedia Grabber is open-sourced software licensed under the [MIT license](LICENSE.md).
[
](https://buymeacoffee.com/dmitry.ivanov)