跳至
采集与统计
期数
期差<option value="5" >5<option value="10" >10<option value="15" >15<option value="20" >20main($start, $end)){
echo '采集完成';
}
}else{
$qishu = isset($_GET['qishu']) ? intval($_GET['qishu']) : 0;
$cha =isset($_GET['cha']) ? intval($_GET['cha']) : 0;
$chas = 'chas'.$cha;
$$chas = 'selected="selected"';
if($_GET){
$_list = $Ss->detachNum();
$list = array();
$n = $i = $qishu;
$num_arr = array();
for( $i; $i = $qishu-$cha; $n-- ){
if(!in_array($n, $num_arr))
$num_arr[] = $n;
}
sort($num_arr);
$list = array();
foreach($num_arr as $key => $val){
$list[] = $_list[$val];
}
$dispose = $Ss->dataDispose( $list, $qishu);
$red = $dispose['red'];
$blue = $dispose['blue'];
?>期数红蓝 $val){
$style = '';
if($val[0]==$qishu){
$style="style='background: #EBE6A9;'";
}
?><tr >红次数权值均值<?php
for($i=1;$i蓝次数权值均值<?php
for($i=1;$i
" _ue_custom_node_="true">
ログイン後にコピー
_list = $this->getFile();
for( $i=$start; $i<=$end; $i++ ){
$url = str_ireplace('*',$i,$this->purl);
$this->getContent($url);
}
return true;
}
function getContent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if(!$data){
return '';
}
# 切割整个页面
$content = explode('',$data);
$content = explode('',$content[1]);
# 匹配数据
preg_match_all("/(.*?)<\/tr>/is", $content[0] ,$out);
unset($out[1][0]);
$con_all = $out[1];
$qishu = null;
ob_start();
foreach($con_all as $key => $val){
preg_match("/(.*?)<\/td>/", $val,$matches_1);
$title = $matches_1[2];
preg_match("/<\/td>/", $val,$matches_2);
$value = $matches_2[2];
$str = trim($title.':'.$value);
if(!in_array($str,$this->_list)){
echo "\n".$str;
}
}
$ob_content = ob_get_contents();
ob_end_clean();
$this->saveFile($ob_content);
}
#保存文件
function saveFile($data){
if(!is_file($this->files)){
$fp = fopen($this->files,'w+');
}else{
$fp = fopen($this->files,'a+');
}
fwrite($fp, $data);
fclose($fp);
}
#取文件 为数组
function getFile(){
$arr = array();
if(!is_file($this->files)){
return $arr;
}
$fp = fopen($this->files,'r');
while (!feof($fp)) {
$arr[] = trim(fgets($fp));
}
fclose($fp);
return $arr;
}
function detachNum(){
$file_list = $this->getFile();
array_shift($file_list);
$reu = array();
foreach($file_list as $key => $val){
$temp = $this->getLayout($val);
$reu[$temp[0]] = $temp;
}
return $reu;
}
function getLayout($data){
$reu = array();
$reu = explode(':',$data);
$reu[2] = substr($reu[1], -2, 2);
$reu[1] = substr($reu[1],0,strlen($reu[1])-2);
return $reu;
}
# 数据处理
function dataDispose($data,$qishu){
if(!is_array($data)) return false;
$coun = count($data);
$foolr = floor($coun/2);
$foolr_qishu = $foolr+1;
$red = array();
$blue = array();
$num = 1;
foreach($data as $key => $val){
if($val[0] == $qishu){
$num = $foolr;
$weight_num = $foolr_qishu;
}elseif($val[0]<$qishu){
$weight_num = $num ++;
}elseif($val[0]>$qishu){
$weight_num = $num --;
}
# 红
$son_arr = $this->stringNumber($val[1]);
foreach($son_arr as $k2 => $v2){
$red[intval($v2)]['hits'] = $red[intval($v2)]['hits']+1;
$red[intval($v2)]['weight'] = $red[intval($v2)]['weight']+$weight_num;
}
# 蓝
$blue[intval($val[2])]['hits'] = $blue[intval($val[2])]['hits']+1;
$blue[intval($val[2])]['weight'] = $blue[intval($val[2])]['weight']+$weight_num;
}
for( $i=0; $i<=33 ;$i++ ){
if($red[$i]){
$red[$i]['mean'] = round($red[$i]['hits']/$red[$i]['weight'],2) ;
}
}
for( $i=0; $i<=16 ;$i++ ){
if($blue[$i]){
$blue[$i]['mean'] = round($blue[$i]['hits']/$blue[$i]['weight'],2);
}
}
return array( 'red'=>$red, 'blue'=>$blue);
}
function stringNumber($string){
$list = array();
$list[] = substr($string, 0, 2);
$list[] = substr($string, 2, 2);
$list[] = substr($string, 4, 2);
$list[] = substr($string, 6, 2);
$list[] = substr($string, 8, 2);
$list[] = substr($string, 10, 2);
return $list;
}
// function dbMysql(){
// $conn = mysql_connect('localhost','root','root') or die('连接Mysql错误:'.mysql_error());
// mysql_select_db('caipiao',$conn) or die('连接数据库错误:'.mysql_error());
// mysql_query('set names gbk');
// }
}
// 采集数据
//$start = 1;
//$end = 1;
//$Ss = new getSseqiu();
//$Ss->main($start, $end);
?>
ログイン後にコピー