PHP code example of wsmwason / taiwan-news-parser

1. Go to this page and download the library: Download wsmwason/taiwan-news-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wsmwason / taiwan-news-parser example snippets


use wsmwason\TaiwanNewsParser\TaiwanNewsParser;
use wsmwason\TaiwanNewsParser\NewsEntry;

$url = 'http://www.appledaily.com.tw/realtimenews/article/animal/20160518/864733/';
$parser = new TaiwanNewsParser();
$newsEntry = $parser->parseUrl($url);

// 取得來源網址
$newsEntry->getUrl();

// 取得新聞出產者
$newsEntry->getCompanyName();

// 取得新聞標題
$newsEntry->getTitle();

// 取得新聞內文
$newsEntry->getContent();

// 取得記者名稱
$newsEntry->getReporterName();

// 取得新聞發布時間
$newsEntry->getPublishTime();

// 取得新聞標籤
$newsEntry->getTags();

// 取得新聞縮圖
$newsEntry->getThumbnailImage();