php抓取中国银行美元汇率源码

`<?php
$data = file_get_contents('https://www.boc.cn/sourcedb/whpj/');
$data = str_replace(array("\r","\n","\t"," ","class=\"pjrq\""), "",$data);
$s = strrpos($data,'<td>美元</td>');
$l = strrpos($data,'<td>南非兰特</td>');
$data = substr($data,$s,$l-$s-14);
$data = str_replace('<td>',"",$data);
$data = str_replace('</td>',",",$data);
$rate = explode(',',$data);
echo '现汇买入价:'.($rate[1]/100).'<hr />现钞买入价:'.($rate[2]/100).'


现汇卖出价:'.($rate[3]/100).'<hr />现钞卖出价:'.($rate[4]/100).'
中行折算价:'.($rate[5]/100).'<hr />更新时间:'.substr($rate[6],0,10).'
更新时间:'.$rate[7];
?>`

标签: 中国银行汇率

添加新评论