request->get('do'); //采集学校数据 if($do=='school') { $sql = "select * from {{%collect_content}} where status=1 order by id asc limit 1"; $schoolResult = Yii::$app->db->createCommand($sql)->queryOne(); if(empty($schoolResult)){exit("导入院校完成");} $schoolInfo = string2array($schoolResult['data']); $sql = "insert into {{%ky_school}} set region_name='".$schoolInfo['region']."',title='".$schoolInfo['title']."',special='".$schoolInfo['special']."',logo='".addslashes($schoolInfo['logo'])."',owner='".$schoolInfo['owner']."'"; Yii::$app->db->createCommand($sql)->execute(); $sql = "update {{%collect_content}} set status=2 where id = ".$schoolResult['id']; Yii::$app->db->createCommand($sql)->execute(); echo ""; exit; } //采集专业数据 if($do=='major') { $sql = "select * from {{%ky_major}} where status=0 and parent_id=0 order by id asc limit 1"; $parentMajor = Yii::$app->db->createCommand($sql)->queryOne(); if(empty($parentMajor)){exit("采集专业完成");} $parentCode = $parentMajor['type'].$parentMajor['code']; $data = ['method'=>'subCategoryMl','key'=>$parentCode]; $result = https_request('https://yz.chsi.com.cn/zyk/specialityCategory.do',[],$data); preg_match_all("/
考试方式: | ',' | '); $direction = $this->cut_html($result,'研究方向: | ',' | '); $learn_way = $this->cut_html($result,'学习方式: | ',' | '); $student_num = $this->cut_html($result,'拟招人数: | ',' | '); $exam_content = $this->cut_html($result,'或 | ','',$result);
$result = preg_replace('/]*class="sub-msg"[^>]*>(.*?)<\/span>/i','',$result);
preg_match_all('/