Home >php教程 >PHP源码 >读取团购网站的api的php程序

读取团购网站的api的php程序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:25:151108browse
<script>ec(2);</script>

读取团购网站的api的php教程程序

$arr = array(
 array("http://www.meituan.com/api/deals/hao123","url","美团网"),

);

class AminoAcid {
    var $name;
    var $symbol;
    var $code;
    var $type;
    function AminoAcid ($aa){
        foreach ($aa as $k=>$v)
            $this->$k = $aa[$k];
    }
}
function readDatabase($filename,$label){
    $data = implode("",file($filename));
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $data, $values, $tags);
    xml_parser_free($parser);
    foreach ($tags as $key=>$val) {
        if ($key == $label) {
            $molranges = $val;
            for ($i=0; $i                 $offset = $molranges[$i] + 1;
                $len = $molranges[$i + 1] - $offset;
                $tdb[] = parseMol(array_slice($values, $offset, $len));
            }
        } else {
            continue;
        }
    }
    return $tdb;
}
function parseMol($mvalues){
    for ($i=0; $i         $mol[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
    }
    return new AminoAcid($mol);
}

foreach($arr as $key => $value){
   $r = readDatabase($value[0],$value[1]);
   print_r($r);//打印出来解析出来的信息
 }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn