谢谢大家和女孩们让它工作了
//创建一个函数
function get_stock_data($ symbol){
//设置要调用的url
$ revenue_url =" http://finance.yahoo.com/q/is?s="。$符号;
//卷曲电话:
//创建一个新的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'];
}
答案 0 :(得分:1)
最后在更新按钮(页面)脚本中添加以下代码
<script type="text/javascript">
var php_var = "<?php echo $symbol; ?>";
locationInfo="stock_next.php?symbol="+php_var;
setTimeout(function(){
location =locationInfo
},2000)
</script>
您的页面将在几秒钟后自动更新