我寫的代碼從dailyhoroscopes.com網站以八字:解析信息從占星網站
<?php
include('../simple_html_dom.php');
// get DOM from URL or file
$html = file_get_html('http://www.dailyhoroscope.com/?date=yesterday');
$needle = 'var ar_interps = ';
$needle_end = 'var ar_interps_love = ';
foreach($html->find('script') as $e)
if (strpos($e->innertext, $needle) !== false) {
$json = substr($e->innertext, strpos($e->innertext, $needle));
$json = substr($json, 0, strpos($json, $needle_end));
$json = str_replace($needle, '', $json);
$json = str_replace('; ', '', $json);
echo '<pre>';
var_dump(json_decode($json, true));
echo '</pre>';
}
?>
什麼是僅與HTML和JavaScript相同的最佳方式?
你的意思是什麼? – bestprogrammerintheworld 2013-04-09 18:58:57
他意味着抓取ajax然後輸出它 – bwoebi 2013-04-09 19:01:04