예제 #1
0
 public function get_zudui()
 {
     $params = array(3, 1, 33, 4, 15, 44, 40, 17, 33);
     asort($params);
     $result = $this->hero_team_model->get_zudui($params);
     PTrace($result);
 }
예제 #2
0
    public function get_wupin()
    {
        $contents = file_get_contents('http://dtcq.gamedashi.com/itemlist/index.html');
        preg_match_all('/<li class=\\"sus type_all  (.*) (.*)\\">
                    	<a href=\\"(.*)\\">
                    	<div class=\\"myy-cs\\">
                            <img  src=\\"(.*)\\"\\/>
                            <div class=\\"myy-im-s\\"><\\/div>
                        <\\/div>
                        <span>(.*)<\\/span> 
                        <\\/a>
                    <\\/li>
/', $contents, $content1);
        $array = array();
        foreach ($content1[3] as $key => $v) {
            $v = str_replace('/itemlist/', '', $v);
            $v = str_replace('.html', '', $v);
            if ($content1[1][$key] == 'color_1') {
                $array[$v]['level'] = '白色';
            } else {
                if ($content1[1][$key] == 'color_2') {
                    $array[$v]['level'] = '绿色';
                } else {
                    if ($content1[1][$key] == 'color_3') {
                        $array[$v]['level'] = '蓝色';
                    } else {
                        if ($content1[1][$key] == 'color_4') {
                            $array[$v]['level'] = '紫色';
                        } else {
                            if ($content1[1][$key] == 'color_5') {
                                $array[$v]['level'] = '橙色';
                            }
                        }
                    }
                }
            }
            if ($content1[2][$key] == 'type_1') {
                $array[$v]['type'] = '零件';
            } else {
                if ($content1[2][$key] == 'type_2') {
                    $array[$v]['type'] = '合成品';
                } else {
                    if ($content1[2][$key] == 'type_3') {
                        $array[$v]['type'] = '消耗品';
                    } else {
                        if ($content1[2][$key] == 'type_4') {
                            $array[$v]['type'] = '卷轴';
                        }
                    }
                }
            }
        }
        foreach ($content1[3] as $key => $v) {
            $url = 'http://dtcq.gamedashi.com/' . $v;
            //$url='http://dtcq.gamedashi.com/itemlist/16.html';
            $content2 = file_get_contents($url);
            $v = str_replace('/itemlist/', '', $v);
            $v = str_replace('.html', '', $v);
            preg_match('/<h3>
                <span class=\\"(.*)\\">(.*)<em>(.*)<\\/em><\\/span> 
                <p><b class=\\"x-gold\\">(.*)<\\/b> \\| (.*)<\\/p>
                <\\/h3>/', $content2, $rs1);
            $isFlag = 1;
            if (!$rs1) {
                $isFlag = 0;
                preg_match('/<h3>
                <span class=\\"(.*)\\">(.*)<\\/span> 
                <p><b class=\\"x-gold\\">(.*)<\\/b> \\| (.*)<\\/p>
                <\\/h3>/', $content2, $rs1);
            }
            //物品名称
            $goodsName = $rs1[2];
            // 等级要求
            if ($isFlag == 1) {
                $goodsDengji = str_replace('(', '', $rs1[3]);
                $goodsDengji = str_replace(')', '', $goodsDengji);
            }
            if ($isFlag == 1) {
                //金额
                $gold = $rs1[4];
                // 说明
                $description = $rs1[5];
            } else {
                $gold = $rs1[3];
                $description = $rs1[4];
            }
            PTrace($gold);
            PTrace($description);
            die;
            // 装备效果
            preg_match_all('/<td> ([^<>]+)<\\/td>/', $content2, $rs2);
            $xiaoguo = implode(',', $rs2[1]);
            //获取途径
            preg_match_all('/<td>([^<>]+)<\\/td>/', $content2, $rs3);
            $length1 = count($rs2[1]) - 1;
            $length2 = count($rs3[1]) - 1;
            $rs8 = array();
            for ($i = $length1 + 1; $i <= $length2; $i++) {
                array_push($rs8, $rs3[1][$i]);
            }
            $rs8 = implode(',', $rs8);
            preg_match_all('/<table[^>]+>(.*)<\\/table>/isU', $content2, $rs5);
            if (isset($rs5[0][0])) {
                preg_match_all('/<a href=\\"\\/itemlist\\/(.*).html\\">
                    <div class=\\"myy-cs\\">
                	<img  src=\\"http:\\/\\/dtcq.gamedashi.com\\/images\\/itemicon\\/(.*).jpg\\"\\/>
                    <div class=\\"myy-im-s\\"><\\/div>
                	<\\/div>
                    <\\/a>
                    <span>(.*)<\\/span>/', $rs5[0][0], $rs6);
            }
            if (isset($rs5[0][1])) {
                preg_match_all('/<a href=\\"\\/itemlist\\/(.*).html\\">
                    <div class=\\"myy-cs\\">
                	<img  src=\\"http:\\/\\/dtcq.gamedashi.com\\/images\\/itemicon\\/(.*).jpg\\"\\/>
                    <div class=\\"myy-im-s\\"><\\/div>
                	<\\/div>
                    <\\/a>
                    <span>(.*)<\\/span>/', $rs5[0][1], $rs7);
            }
            $tobe = $be = '';
            if (isset($rs6) && count($rs6) > 1) {
                //可合成
                $tobe = implode(',', $rs6[1]);
            }
            if (isset($rs7) && count($rs7) > 1) {
                //合成
                $be = implode(',', $rs7[1]);
            }
            $params['id'] = $v;
            $params['goods_name'] = $goodsName;
            $params['goods_dengji'] = $goodsDengji;
            $params['golds'] = $gold;
            $params['description'] = $description;
            $params['xiaoguo'] = $xiaoguo;
            $params['tujin'] = $rs8;
            $params['tobe'] = $tobe;
            $params['be'] = $be;
            $params['color'] = $array[$v]['level'];
            $params['type'] = $array[$v]['type'];
            $params['goods_img'] = 'http://dotachuanqi.com/upload/goods_img/' . $v . '.jpg';
            $this->goods_model->save($params);
            $filename = IMGPATH . 'goodsImg' . DIRECTORY_SEPARATOR . $v . '.jpg';
            $this->GrabImage($content1[4][$key], $filename);
            if (isset($rs5[0][2])) {
                preg_match_all('/<a href=\\"\\/cards\\/(.*).html\\">
                    <div class=\\"her-box\\">
                	<img  src=\\"(.*)\\"\\/>
                    <div class=\\"her-box-bor(.*)\\"><\\/div>
                	<\\/div>
                	<span class=\\"(.*)\\">([^<>]+)<\\/span>
                    <\\/a>
/', $rs5[0][2], $rs9);
            } else {
                if (isset($rs5[0][1])) {
                    preg_match_all('/<a href=\\"\\/cards\\/(.*).html\\">
                    <div class=\\"her-box\\">
                	<img  src=\\"(.*)\\"\\/>
                    <div class=\\"her-box-bor(.*)\\"><\\/div>
                	<\\/div>
                	<span class=\\"(.*)\\">([^<>]+)<\\/span>
                    <\\/a>
/', $rs5[0][1], $rs9);
                }
            }
            if (isset($rs9) && $rs9) {
                $params3['goods_id'] = $v;
                $params3['hero_id'] = implode(',', $rs9[1]);
                $params3['message'] = implode(',', $rs9[5]);
                $this->goods_hero_model->save($params3);
            }
        }
    }