10月20日,北京【人工智能】源创会火热报名中,点击报名收获 AI 训练指南
Watch Star Fork

pycorvn / RMB汇率转换接口PHP

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
通过抓取和讯网RMB比价中心数据,解析出需要的银行及币种汇率
pycorvn 最后提交于 no commit message
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md 2.25 KB

RMB汇率转换接口

Description

通过抓取和讯网RMB比价中心数据,解析出需要的银行及币种汇率

Software Architecture

<?php

    $data = file_get_contents('http://data.bank.hexun.com/other/cms/foreignexchangejson.ashx');
    $data = iconv('gbk', 'utf-8', $data);
    $data = preg_replace('/},{/', '|', substr($data, 22, -3));
    $data = explode('|', $data);
    $list = [];
    foreach($data as $v) {
        $v = explode(',', $v);
        $item = [];
        foreach($v as $o) {
            $p = strpos($o, ':');
            $item[substr($o, 0, $p)] = trim(substr($o, $p+1), '\'');
        }
        array_push($list, $item);
    }
    header('Content-Type:text/html;charset=utf-8');
    echo '<pre>';
    print_r($list);
    
    /**
    Array
    (
        [0] => Array
            (
                [bank] => 工商银行
                [currency] => 阿联酋 迪拉姆
                [code] =>
                [currencyUnit] =>
                [cenPrice] =>
                [buyPrice1] => 171.8200
                [sellPrice1] => 173.0900
                [buyPrice2] => 166.4400
                [sellPrice2] => 173.0900
                [releasedate] => 2018-4-27 23:37:35
            )

        [1] => Array
            (
                [bank] => 工商银行
                [currency] => 澳大利亚元
                [code] => AUD
                [currencyUnit] =>
                [cenPrice] =>
                [buyPrice1] => 478.1600
                [sellPrice1] => 481.7100
                [buyPrice2] => 464.4900
                [sellPrice2] => 481.7100
                [releasedate] => 2018-4-30 9:05:54
            )
        ...
    **/

Contribution

  1. Fork the project
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Gitee Feature

  1. You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md
  2. Gitee blog blog.gitee.com
  3. Explore open source project https://gitee.com/explore
  4. The most valuable open source project GVP
  5. The manual of Gitee http://git.mydoc.io/
  6. The most popular members https://gitee.com/gitee-stars/

项目点评 ( 0 )

你可以在登录后,发表评论

搜索帮助