2017 © Pedro Peláez
 

library apist

Package to provide api-like access to foreign sites based on html parsing

image

sleeping-owl/apist

Package to provide api-like access to foreign sites based on html parsing

  • Wednesday, April 29, 2015
  • by sleeping-owl
  • Repository
  • 27 Watchers
  • 313 Stars
  • 1,425 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 43 Forks
  • 2 Open issues
  • 12 Versions
  • 1 % Grown

The README.md

SleepingOwl Apist

Build Status Latest Stable Version Total Downloads License Code Climate, (*1)

SleepingOwl Apist is a small library which allows you to access any site in api-like style, based on html parsing., (*2)

Overview

This package allows you to write method like this:, (*3)

class WikiApi extends Apist
{

    public function getBaseUrl()
    {
        return 'http://en.wikipedia.org';
    }

    public function index()
    {
        return $this->get('/wiki/Main_Page', [
            'welcome_message'  => Apist::filter('#mp-topbanner div:first')->text()->mb_substr(0, -1),
            'portals'          => Apist::filter('a[title^="Portal:"]')->each([
                'link'  => Apist::current()->attr('href')->call(function ($href)
                {
                    return $this->getBaseUrl() . $href;
                }),
                'label' => Apist::current()->text()
            ]),
            'languages'        => Apist::filter('#p-lang li a[title]')->each([
                'label' => Apist::current()->text(),
                'lang'  => Apist::current()->attr('title'),
                'link'  => Apist::current()->attr('href')->call(function ($href)
                {
                    return 'http:' . $href;
                })
            ]),
            'sister_projects'  => Apist::filter('#mp-sister b a')->each()->text(),
            'featured_article' => Apist::filter('#mp-tfa')->html()
        ]);
    }
}

and get the following result:, (*4)

{
    "welcome_message": "Welcome to Wikipedia",
    "portals": [
        {
            "link": "http:\/\/en.wikipedia.org\/wiki\/Portal:Arts",
            "label": "Arts"
        },
        {
            "link": "http:\/\/en.wikipedia.org\/wiki\/Portal:Biography",
            "label": "Biography"
        },
        ...
    ],
    "languages": [
        {
            "label": "Simple English",
            "lang": "Simple English",
            "link": "http:\/\/simple.wikipedia.org\/wiki\/"
        },
        {
            "label": "العربية",
            "lang": "Arabic",
            "link": "http:\/\/ar.wikipedia.org\/wiki\/"
        },
        {
            "label": "Bahasa Indonesia",
            "lang": "Indonesian",
            "link": "http:\/\/id.wikipedia.org\/wiki\/"
        },
        ...
    ],
    "sister_projects": [
        "Commons",
        "MediaWiki",
        ...
    ],
    "featured_article": "<div style=\"float: left; margin: 0.5em 0.9em 0.4em 0em;\">...<\/div>"
}

Installation

Require this package in your composer.json and run composer update (or run composer require sleeping-owl/apist:1.x directly):, (*5)

    "sleeping-owl/apist": "1.*"

Documentation

Documentation can be found at sleeping owl apist., (*6)

Examples

View examples., (*7)

Support Library

You can donate via PayPal, Yandex money (410012943296949) or in BTC: 13k36pym383rEmsBSLyWfT3TxCQMN2Lekd, (*8)

Apist was written by Sleeping Owl and is released under the MIT License. See the LICENSE file for details., (*9)

The Versions

29/04 2015

dev-master

9999999-dev http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

10/03 2015

1.3.7

1.3.7.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

04/03 2015

1.3.6

1.3.6.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

10/02 2015

1.3.5

1.3.5.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

19/01 2015

1.3.4

1.3.4.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

18/11 2014

1.3.3

1.3.3.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

10/11 2014

1.3.2

1.3.2.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

31/10 2014

1.3.1

1.3.1.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

30/10 2014

1.3.0

1.3.0.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

25/10 2014

1.2.0

1.2.0.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

24/10 2014

1.1.0

1.1.0.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler

22/10 2014

1.0.0

1.0.0.0 http://sleeping-owl-apist.gopagoda.com

Package to provide api-like access to foreign sites based on html parsing

  Sources   Download

MIT

The Requires

 

The Development Requires

api crawler