-1
我想每天更新一次example_homepage.html,怎麼樣?如何每天更新一次
<?php
$ch = curl_init("http://rss.news.yahoo.com/rss/oddlyenough");
$fp = fopen("example_homepage.html", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$xml = simplexml_load_file('example_homepage.html');
print "<ul>\n";
foreach ($xml->channel->item as $item){
print "<li>$item->title</li>\n";
}
print "</ul>";
?>
你知道我的意思嗎?這個頁面非常慢,所以我希望每天更新一次example_homepage.html。但我不知道該怎麼辦?
就應該添加cron作業每天一次? – 2014-11-01 13:27:51
您可以檢查文件的修改時間。如果你可以使用cron,然後使用cron,則可以使用 – Gumbo 2014-11-01 13:29:11
。如果不能,則創建一個文本文件,在該文件中存儲該日期是否被緩存。如果沒有,那麼當有人調用頁面時,創建緩存文件,存儲日期。如果是,則顯示緩存頁面。 – vaso123 2014-11-01 13:39:45