|
@@ -26,7 +26,6 @@ class Sina
|
|
|
$content3 = substr($content2, stripos($content2, "=\"") + 2); //获取 var hq_str_sz000002="万 科A,30.780,30.800,30.510, ="之后部分
|
|
$content3 = substr($content2, stripos($content2, "=\"") + 2); //获取 var hq_str_sz000002="万 科A,30.780,30.800,30.510, ="之后部分
|
|
|
$content4 = substr($content3, 0, strripos($content3, "\";")); //获取 万 科A,30.94,0.14,0.45,584039,178827"; ";之前部分
|
|
$content4 = substr($content3, 0, strripos($content3, "\";")); //获取 万 科A,30.94,0.14,0.45,584039,178827"; ";之前部分
|
|
|
$content5 = explode(",", $content4);//分割
|
|
$content5 = explode(",", $content4);//分割
|
|
|
-
|
|
|
|
|
return $content5;
|
|
return $content5;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -106,6 +105,29 @@ class Sina
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/****
|
|
/****
|
|
|
|
|
+ * @param $code
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * 判断股票的类型,属于创业板,科创板,主板,$code
|
|
|
|
|
+ */
|
|
|
|
|
+ static public function get_boniu_block($code)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (strncmp($code, "30", 2) == 0) {
|
|
|
|
|
+ //创业板
|
|
|
|
|
+ $code .= "sz";
|
|
|
|
|
+ } else if (strncmp($code, "68", 2) == 0) {
|
|
|
|
|
+ //科创板
|
|
|
|
|
+ $code .= "sh";
|
|
|
|
|
+ } else if (strncmp($code, "60", 2) == 0) {
|
|
|
|
|
+ //主板
|
|
|
|
|
+ $code .= "sh";
|
|
|
|
|
+ } else if (strncmp($code, "00", 2) == 0) {
|
|
|
|
|
+ //中小板
|
|
|
|
|
+ $code .= "sz";
|
|
|
|
|
+ }
|
|
|
|
|
+ return $code;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ /****
|
|
|
* @param string $code
|
|
* @param string $code
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
//上证指数表(boniu_index_sh)
|
|
//上证指数表(boniu_index_sh)
|
|
@@ -255,13 +277,14 @@ class Sina
|
|
|
* 根据股票代码获取股票的实时信息
|
|
* 根据股票代码获取股票的实时信息
|
|
|
*/
|
|
*/
|
|
|
static public function get_info_code($code){
|
|
static public function get_info_code($code){
|
|
|
- $stock_code = $code;
|
|
|
|
|
- $f = substr($stock_code, 0, 1);
|
|
|
|
|
- if ($f == "6" || $f == "0" ) {
|
|
|
|
|
- $stock_code = "sh" . $code;
|
|
|
|
|
- } else {
|
|
|
|
|
- $stock_code = "sz" . $code;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// $stock_code = $code;
|
|
|
|
|
+// $f = substr($stock_code, 0, 1);
|
|
|
|
|
+// if ($f == "6" || $f == "0" ) {
|
|
|
|
|
+// $stock_code = "sh" . $code;
|
|
|
|
|
+// } else {
|
|
|
|
|
+// $stock_code = "sz" . $code;
|
|
|
|
|
+// }
|
|
|
|
|
+ $stock_code= self::get_boniu_block($code);
|
|
|
$url = "http://hq.sinajs.cn/list=" . $stock_code;
|
|
$url = "http://hq.sinajs.cn/list=" . $stock_code;
|
|
|
$content3=sina::curl_get_data($url);//封装为函数,执行url获取结果并解析
|
|
$content3=sina::curl_get_data($url);//封装为函数,执行url获取结果并解析
|
|
|
return $content3;
|
|
return $content3;
|
|
@@ -298,6 +321,9 @@ class Sina
|
|
|
|
|
|
|
|
//除权除息表(boniu_xrxd_log)
|
|
//除权除息表(boniu_xrxd_log)
|
|
|
//st记录表(boniu_st_log)
|
|
//st记录表(boniu_st_log)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//获取历史数据的表
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
?>
|