Git Product home page Git Product logo

tw-stock-crawler-php's Introduction

Taiwan Stock Crawler by PHP

PHP Crawler for Taiwan Stock Data (台股資料爬蟲)

Latest Stable Version License

OUTLINE


REQUIREMENTS

This library requires the following:

  • PHP 5.4.0+|7.0+

INSTALLATION

Run Composer in your project:

composer require yidas/tw-stock-crawler

Then you could call it after Composer is loaded depended on your PHP framework:

require __DIR__ . '/vendor/autoload.php';

use yidas\twStockCrawler\Crawler;

USAGE

You could first configure the crawler with source or stockId, and then call the function you need.

$parser = \yidas\twStockCrawler\Crawler::config(["source"=>"twse"]);
$parser::setStockId("2330");
$priceData2330 = $parser::getLastPrice();
$priceData2454 = $parser::getLastPrice("2454");
$companyData2330 = $parser::getCompanyData();

Alternative source:

  • "Yahoo" (default): Acceptable access restrictions
  • "TWSE": Strict access restrictions

Company Data

Crawler::getCompanyData("2330");:

Array
(
    [id] => 2330
    [isOTC] =>
    [title] => 台積電
    [industry] => 半導體
)

Price

  • Last Price

Crawler::getLastPrice("2330");:

Array
(
    [date] => 20210517
    [timestamp] => 13:30:00
    [amount] => 549
)

EPS

Crawler::getEPS("2330", 2020);

Array
(
    [0] => Array
        (
            [year] => 2020
            [amount] => 19.98
            [details] => Array
                (
                    [0] => Array
                        (
                            [year] => 2020
                            [belong] => Q4
                            [amount] => 5.51
                        )

                    [1] => Array
                        (
                            [year] => 2020
                            [belong] => Q3
                            [amount] => 5.3
                        )

                    [2] => Array
                        (
                            [year] => 2020
                            [belong] => Q2
                            [amount] => 4.66
                        )

                    [3] => Array
                        (
                            [year] => 2020
                            [belong] => Q1
                            [amount] => 4.51
                        )
                )
        )
)

Dividend

  • Dividend by year

Crawler::getDividend("2454", 2009);:

Array
(
    [year] => 2009
    [cash] => 26
    [stock] => 0.02
    [total] => 26.02
    [details] => Array
        (
            [0] => Array
                (
                    [year] => 2009
                    [belong] => 2009
                    [cash] => 26
                    [cashReleaseYear] => 2010
                    [cashReleaseDate] => 2010/08/26
                    [stock] => 0.02
                    [stockReleaseYear] =>
                    [stockReleaseDate] => 2010/08/26
                    [total] => 26.02
                )
        )
)
  • Dividend by half year

Crawler::getDividend("5283", 2019);:

Array
(
    [year] => 2019
    [cash] => 8.16
    [stock] => 0
    [total] => 8.16
    [details] => Array
        (
            [0] => Array
                (
                    [year] => 2019
                    [belong] => H2
                    [cash] => 4.16
                    [cashReleaseYear] => 2020
                    [cashReleaseDate] => 2020/09/29
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 4.16
                )

            [1] => Array
                (
                    [year] => 2019
                    [belong] => H1
                    [cash] => 4
                    [cashReleaseYear] => 2020
                    [cashReleaseDate] => 2020/04/20
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 4
                )
        )
)
  • Dividend by season

Crawler::getDividend("2330", 2020);:

Array
(
    [year] => 2020
    [cash] => 10
    [stock] => 0
    [total] => 10
    [details] => Array
        (
            [0] => Array
                (
                    [year] => 2020
                    [belong] => Q4
                    [cash] => 2.5
                    [cashReleaseYear] => 2021
                    [cashReleaseDate] => 2021/07/14
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 2.5
                )

            [1] => Array
                (
                    [year] => 2020
                    [belong] => Q3
                    [cash] => 2.5
                    [cashReleaseYear] => 2021
                    [cashReleaseDate] => 2021/04/14
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 2.5
                )

            [2] => Array
                (
                    [year] => 2020
                    [belong] => Q2
                    [cash] => 2.5
                    [cashReleaseYear] => 2021
                    [cashReleaseDate] => 2021/01/13
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 2.5
                )

            [3] => Array
                (
                    [year] => 2020
                    [belong] => Q1
                    [cash] => 2.5
                    [cashReleaseYear] => 2020
                    [cashReleaseDate] => 2020/10/14
                    [stock] =>
                    [stockReleaseYear] =>
                    [stockReleaseDate] =>
                    [total] => 2.5
                )
        )
)

REFERENCES

tw-stock-crawler-php's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

fanwen a905538

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.