浏览代码

修改bug

chenbo 4 年之前
父节点
当前提交
e3525e8e44
共有 4 个文件被更改,包括 39 次插入17 次删除
  1. 25 0
      lib/input_sina_simple.class.php
  2. 0 13
      task/task_get_day_k_index.sh
  3. 2 4
      task/task_get_day_k_index.php
  4. 12 0
      task/task_get_index_day_k.sh

+ 25 - 0
lib/input_sina_simple.class.php

@@ -150,6 +150,31 @@ class Input_sina_simple
         return;
     }
 
+    //获取index_day_k 涨跌幅数据
+    static public function getIndexDayKIncreaseRatio($indexList)
+    {
+        $codeList = array();
+        $codeIndex = 0;
+        $url = self::GLOBAL_URL;
+        foreach ($indexList as $item) {
+            $codeStr = sprintf('%06s', $item['code']);
+            $url .= 's_'.$item['exchange'].$codeStr.',';
+            $codeList[$codeIndex] = $codeStr;
+            $codeIndex++;
+        }
+        $contentList = self::curl_get_data($url, $codeList);
+        foreach ($contentList as $key => $item) {
+            $data['code'] = $item['code'];
+            $data['name'] = trim($item[0]);
+            $data['date'] = date('Ymd',time());
+            $data['increase_ratio'] = floatval(trim($item[3]));
+            if (!empty($item[0])) {                            //判断非法股票代码
+                Index_day_k::addOrUpdateByCodeDate($data);
+            }
+        }
+        return;
+    }
+
 }
 
 ?>

+ 0 - 13
task/task_get_day_k_index.sh

@@ -1,13 +0,0 @@
-#!/bin/sh
-
-
-
-cd /home/wwwroot/default/boniu/task
-echo '正在获取所有获取当天的指数数据...'
-nohup php ./task_get_day_k_index.php &
-
-sleep 86400s
-echo "完成!"
-rm -f nohup.out
-sleep 1s
-

+ 2 - 4
task/task_get_day_k_index.php

@@ -7,10 +7,8 @@
  * 获取指数的当天数据,一天大概6条数据入库
  */
 require('../init.php');
-$indexList=Index::getAllList();//获取指数代码
-foreach ($indexList as $key=>$value){
-    Input_sina_index::get_day_k_index($value["code"],$value["exchange"]);
-}
 
+$indexList = Index::getAllList();//获取指数代码
+Input_sina_simple::getIndexDayKIncreaseRatio($indexList);
 
 ?>

+ 12 - 0
task/task_get_index_day_k.sh

@@ -0,0 +1,12 @@
+#!/bin/sh
+
+
+
+cd /home/wwwroot/default/boniu/task
+echo '正在获取指数日K数据...'
+nohup php ./task_get_index_day_k.php &
+sleep 5s
+echo "完成!"
+f
+sleep 1s
+