首页 >后端开发 >php教程 >php获得股票数据

php获得股票数据

WBOY
WBOY原创
2016-08-08 09:06:342116浏览

$stock_string="http://hq.sinajs.cn/list=sh601006";
echo file_get_contents($stock_string);
?>

获得输出:
var hq_str_sh601006="大秦铁路,6.100,6.120,6.110,6.140,6.090,6.100,6.110,20493711,125311065.000,894866,6.100,986200,6.090,1065300,6.080,596400,6.070,912000,6.060,122486,6.110,1106900,6.120,1318700,6.130,1221000,6.140,1334900,6.150,2016-08-05,15:00:00,00";
用php完成
1.如何提取出字符串
"大秦铁路,6.100,6.120,6.110,6.140,6.090,6.100,6.110,20493711,125311065.000,894866,6.100,986200,6.090,1065300,6.080,596400,6.070,912000,6.060,122486,6.110,1106900,6.120,1318700,6.130,1221000,6.140,1334900,6.150,2016-08-05,15:00:00,00"
2.用一个数组来装这个字符串?

回复内容:

$stock_string="http://hq.sinajs.cn/list=sh601006";
echo file_get_contents($stock_string);
?>

获得输出:
var hq_str_sh601006="大秦铁路,6.100,6.120,6.110,6.140,6.090,6.100,6.110,20493711,125311065.000,894866,6.100,986200,6.090,1065300,6.080,596400,6.070,912000,6.060,122486,6.110,1106900,6.120,1318700,6.130,1221000,6.140,1334900,6.150,2016-08-05,15:00:00,00";
用php完成
1.如何提取出字符串
"大秦铁路,6.100,6.120,6.110,6.140,6.090,6.100,6.110,20493711,125311065.000,894866,6.100,986200,6.090,1065300,6.080,596400,6.070,912000,6.060,122486,6.110,1106900,6.120,1318700,6.130,1221000,6.140,1334900,6.150,2016-08-05,15:00:00,00"
2.用一个数组来装这个字符串?

这是获取到JS代码,你可以试试

$stock_string="http://hq.sinajs.cn/list=sh601006";
$str = file_get_contents($stock_string);
?>
<script><br><?php echo $str; ?><br>console.log(hq_str_sh601006);<br>//TODO 处理数据<br></script>

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn