<?phpif(isset($_GET['id'])){//处理表单提交的数据if(empty($_GET['id']) || empty($_GET['name'])) die('缺少id或name参数!'); //缺少参数反馈$query_data = 'zkzh='.$_GET['id'].'&xm='.urlencode($_GET['name']); //拼接成URL参数//curl请求开始$ch = curl_init();curl_setopt ($ch, CURLOPT_URL, 'http://www.chsi.com.cn/cet/query'); //请求URLcurl_setopt ($ch, CURLOPT_HEADER, 0);curl_setopt ($ch,CURLOPT_REFERER,'http://www.chsi.com.cn/cet/'); //制造假的REFERERcurl_setopt ($ch, CURLOPT_POST, 0);curl_setopt($ch, CURLOPT_POSTFIELDS, $query_data ); //设置参数数据curl_exec ($ch);curl_close ($ch);}else {?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>四六级成绩查询</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Language" content="zh-CN" /></head><body><style>div{float:left;clear:left;margin:5px;}label,input{width:150px;float:left;}</style><h1>四六级成绩查询</h1><form action="<?php echo $_SERVER['PHP_SELF']; ?>"><div><label for="id">准考证号:</label><input type="text" name="id" id="id"/></div><div><label for="name">姓名:</label><input type="text" name="name" id="name"/></div><div><input type="submit" value="查询"/></div></form></body></html><?php}?>
未经同意禁止转载!
转载请附带本文原文地址:php利用curl获取学信网四六级成绩查询结果,首发自 Zjmainstay学习笔记




