如何自动加载细节
感谢球员和加尔斯让它工作
//创建一个函数function get_stock_data($ symbol){//设置要调用的url $ revenue_url =“http://finance.yahoo.com/q/is?s=".$symbol;
// curl call://创建一个新的cURL资源$ ch = curl_init();
//设置URL和其他适当的选项curl_setopt($ ch,CURLOPT_URL,$ revenue_url); curl_setopt($ ch,CURLOPT_HEADER,0); curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1); //抓取URL并传递给浏览器$ result = curl_exec($ ch);
//关闭cURL资源,释放系统资源curl_close($ ch);
//通过返回结果返回$ result来完成; }
//REQUEST WILL BE POPULATED IF EITHER GET OR POST IS SET!
$data = null; // this will hold our data, declared here for accessibility
if(isset($_REQUEST['symbol']) && $_REQUEST['symbol'] != ''){
//call our get_data function
$data = get_stock_data($_REQUEST['symbol']);
}
// data returned from our get_stock_data() call.
$ppe = $data['ppe'];
$revenue = $data['revenue'];
$income = $data['income'];
$market_cap = $data['market_cap'];
$depreciation = $data['depreciation'];
$rate_of_return = $data['rate_of_return'];
$rate_of_return_w_ppe = $data['rate_of_return_w_ppe'];
$debt = $data['debt'];
}
最后在更新按钮(页面)脚本中添加以下代码
<script type="text/javascript">
var php_var = "<?php echo $symbol; ?>";
locationInfo="stock_next.php?symbol="+php_var;
setTimeout(function(){
location =locationInfo
},2000)
</script>
您的页面会在几秒钟后自动更新
链接地址: http://www.djcxy.com/p/48579.html上一篇: How to load details automatically
下一篇: Bash script curl