include_once('simple_html_dom.php');
以Yahoo科技新聞頭條為例
$url = "https://tw.news.yahoo.com/technology/";
if(false !== ($file = file_get_contents($url)) ){
$html = str_get_html($file);
if($html && is_object($html) && isset($html->nodes)){
echo $html -> find('div.txt',0) -> innertext;
}
}else{
echo 'url有問題';
}
以Yahoo科技新聞頭條為例
$url = "https://tw.news.yahoo.com/technology/";
$file = file_get_contents($url);
$html = str_get_html($file);
echo $html -> find('div.txt',0) -> innertext;
下集待續 讀取存入Parse or Excel~