2015年12月29日 星期二

[Parser] - PHP 抓取網頁內容變成 DOM object

官方網站:http://simplehtmldom.sourceforge.net/
使用說明:http://simplehtmldom.sourceforge.net/manual.htm

抓取  simple_html_dom.php
# wget  http://sourceforge.net/projects/simplehtmldom/files/simple_html_dom.php/download

編輯程式
# vim getdata.php

<?PHP

include_once('simple_html_dom.php');
header("Content-Type:text/html; charset=utf-8");

$url = 'https://xxxx';
$html = file_get_html($url);
$ret = $html->find('a[class=list-button]');

// Find all links

foreach( $ret as $element)
$list[] =  $element->href ;
echo  '<pre>' ; print_r($t) ; echo '</pre>';

// 可把 array list 寫到 DB 或 變成 json 格式

?>

沒有留言:

張貼留言