我写的代码从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