大二学了一下PHP cURL,做了几个demo。

1、代码如下:

index.html

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0"><title>CET查询</title><style type="text/css">*{margin: 0;padding: 0;border: 0;}body{font-family: 微软雅黑;width: 100%;background-color: #f8f8f8}@media (max-width: 450px){.cet_check_form{width: 100%;height: 500px;margin: 0 auto;background-color: ;}}@media (min-width: 450px){.cet_check_form{width: 100%;max-width: 600px;height: 800px;margin: 0 auto;background-color: #f8f8f8;}}.box_img img{width: 100%;}form input{ outline: none;font-family: 微软雅黑;font-size: 16px;transition: all .5s ease;}form input:focus {border-color: rgba(82, 168, 236, 0.8);outline: thin dotted \9;box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);/*margin-top: 10px;*/}p{text-align: center;}.query_cet{width: 90%;height: 40px;padding-left: 5%;/*设置placeholder的位置*/}.submit{width: 90%;height: 50px;color: #fff;font-size: 16px;background-color: rgb(0,140,186);transition: all .5s ease;font-family: 微软雅黑;}.submit:hover{background-color: rgb(0,116,155);}/*input placeholder样式*/:-moz-placeholder { /* Mozilla Firefox 4 to 18 */opacity:.5; }::-moz-placeholder { /* Mozilla Firefox 19+ */opacity:.5;}input:-ms-input-placeholder{opacity:.5;}input::-webkit-input-placeholder{opacity:.5;}input::-webkit-input-placeholder {  /* WebKit browsers*/ opacity:.5;}input:-moz-placeholder {              /* Mozilla Firefox 4 to 18*/ opacity:.5;}input::-moz-placeholder {              /* Mozilla Firefox 19+*/ opacity:.5;}input:-ms-input-placeholder {         /* Internet Explorer 10+*/ opacity:.5;}</style>
</head>
<body>
<form class="cet_check_form" method="post" action="query_CET.php"><div class="box_img"><img src="cet.jpg" ></div><br/><p><input class="query_cet" name="name" type="text"/ required="" placeholder="姓名"></p><br/><p><input class="query_cet" name="num" type="text" required="" placeholder="准考证号"/></p><br/><p><input class="submit" name="submit" type="submit" value="查询"/></p><p align="center" style="font-size: 12px;margin-top: 50px;">(以上数据来之学信网、99宿舍网)<br/><br/>by Vegeta</p>
</form></body>
</html>

query_cet.php

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style type="text/css">*{margin: 0;padding: 0;border: 0;font-family: 微软雅黑;}@media (min-width: 450px){.result_box{width: 100%;max-width: 600px;height: 800px;margin: 0 auto;background-color: #f8f8f8;}}.result_box span{width: 100%;height: 35px;display: block;line-height: 35px;text-align: center;color: #fff;background-color: #123456;}.result_p{width: 95%;height: 35px;margin: 0 0 0 5%;line-height: 35px;font-size: 15px;}.result_p_detel{width: 90%;height: 35px;margin: 0 0 0 10%;color: #666;font-size: 15px;line-height: 25px;}.result_error{text-align: center;}.result_s{font-size: 12px;text-align: center;}
</style><?phperror_reporting(0);include('simple_html_dom.php');header("Content-type:text/html,charset=utf8");$zkzh=$_POST['num'];$xm=$_POST['name'];// $zkzh = '445050162102530';// $xm = 'czq';$curlPost='zkzh='.$zkzh.'&xm='.$xm;$ch = curl_init("http://www.chsi.com.cn/cet/query?".$curlPost) ;  $arrMsg = array();for($i=0;$i<15;$i++){curl_setopt($ch, CURLOPT_REFERER, "http://www.chsi.com.cn/cet/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回  curl_setopt($ch, CURLOPT_HEADER, 1);$output = curl_exec($ch) ;  $html = new simple_html_dom();$html ->load($output);// print_r($output);foreach($html->find("td") as $m) {array_push($arrMsg,$m->plaintext);}if($arrMsg[6]!=null) {
echo<<<begin<div class="result_box"><p class="result_p">姓名:$arrMsg[2]</p><p class="result_p">学校:$arrMsg[3]</p><p class="result_p">考试级别:$arrMsg[4]</p><span>笔试成绩</span><p class="result_p">准考证号:$arrMsg[5]</p><p class="result_p">总分:$arrMsg[6]</p><p class="result_p_detel">听力:$arrMsg[8]</p><p class="result_p_detel">阅读:$arrMsg[10]</p><p class="result_p_detel">写作和翻译:$arrMsg[10]</p><span>口试成绩</span><p class="result_p">准考证号:$arrMsg[13]</p><p class="result_p">等 级:$arrMsg[14]</p><br/><br/><br/><p class="result_s">(以上数据来之学信网、99宿舍网)</p></div>
begin;break;}else{// var_dump($arrMsg);
echo<<<begin<div class="result_box"><br/><br/><p class="result_error">查询失败,请稍后重新查询。</p></div>
begin;break;}}?>

simple_html_dom.php

需要下载php解析html类库:simple_html_dom.php

2、效果截图

PHP cURL学习-大学CET查询相关推荐

  1. PHP cURL学习-域名备案查询

    大二学了一下PHP cURL,做了几个demo. 1.代码如下: index.html <html> <head><meta http-equiv="Conte ...

  2. Java计算机毕业设计天津城建大学教室查询预约管理系统源码+系统+数据库+lw文档

    Java计算机毕业设计天津城建大学教室查询预约管理系统源码+系统+数据库+lw文档 Java计算机毕业设计天津城建大学教室查询预约管理系统源码+系统+数据库+lw文档 本源码技术栈: 项目架构:B/S ...

  3. php实时股票,php中curl实现的股票信息查询的实例详解

    php基于curl实现的股票信息查询类实例 本文实例讲述了php基于curl实现的股票信息查询类.分享给大家供大家参考,具体如下: 股票信息查询功能我们是需要抓取第三方的数据,然后我们再把这些数据进行 ...

  4. SSH学习-Hibernate关联查询

    与MyBatis类似,Hibernate也有关联查询,数据库中表与表之间的关联关系使用主外键的形式体现,实体对象之间的关联关系体现在对象与对象的引用.在Mybatis中,当涉及到复杂查询并且表之间存在 ...

  5. php实时股票,php基于curl实现的股票信息查询类实例

    本文实例讲述了php基于curl实现的股票信息查询类.分享给大家供大家参考,具体如下: 股票信息查询功能我们是需要抓取第三方的数据,然后我们再把这些数据进行分析组成自己想要的,下面我们来看一个php ...

  6. oracle创建自身连接,oracle菜鸟学习之 自连接查询实验

    oracle菜鸟学习之 自连接查询实验 实验表的创建 表字段说明: id:员工编号 name:员工名字 ano:管理人员编号 create table admin(id varchar2(4),nam ...

  7. 每日linux命令学习-历史指令查询(history、fc、alias)

    linux历史机制对命令行中输入的命令进行编号并依此保存,以维护命令历史.登录会话期间输入的命令保存在shell内存中,若终止命令则添加至历史文件. 1. 箭头符号方向键 使用键盘上的箭头方向键可以从 ...

  8. 零基础带你学习MySQL—分页查询(十八)

    零基础带你学习MySQL-分页查询(十八)

  9. JavaScript基础学习 模拟京东查询快递单号

    JavaScript基础学习 模拟京东查询快递单号 <!DOCTYPE html> <html lang="en"><head><meta ...

最新文章

  1. Python_Day4_函数
  2. 测试面试话题5: 如何不漏测
  3. 函数递归方法反转字符串
  4. Topk 问题详解及代码和数据分析
  5. 【渝粤教育】国家开放大学2019年春季 1124流行病学 参考试题
  6. 漫步最优化四——约束
  7. Nodejs中原生遍历文件夹
  8. countdownlatch的使用详解(好懂!!)
  9. Oracle 20c 新特性:表空间缺省加密算法 TABLESPACE_ENCRYPTION_DEFAULT_ALGORITHM
  10. matlab hpopup2,matlabpopupmenu的问题
  11. 腾讯QQ珊瑚虫外挂原理分析
  12. 【刘润五分钟商学院】-164一眼识别诡辩论的五个方法
  13. 教你制作专属个性二维码!将照片制作成二维码图片!给二维码添加背景图片!
  14. Delphi导出word
  15. 为什么Windows编程都用UNICODE
  16. 手机闪存速度排行_手机闪存读写速度对比?一加不如iQOO,华为最强,默秒全...
  17. Lumerical官方案例、FDTD时域有限差分法仿真学习(三)——环形谐振器(Ring resonator)之第二&第三部分
  18. 杰奇后台乱码,安装杰奇程序后后台出现很多问号
  19. Django——mako的配置与使用方法
  20. C语言编写的判断素数的程序

热门文章

  1. 【Android】Bluetooth(蓝牙)连接与数据传输(一)
  2. React_lazy使用-组件加载前loading做优雅降级
  3. “《正在爆发的互联网革命》——30余位互联网大腕一致推荐,3.5亿网民必看!”
  4. 银联内核与pboc内核的区别(闪付流程)
  5. 微服务商城系统(十六)秒杀核心
  6. Sallen-Key滤波器的详细介绍
  7. 小米商场系统的购物网站的具体的功能实现(重点讲下订单的生成)
  8. win10, net framework 3.5 安装报错0x800F081F
  9. 图片URL链接下载到本地(https)
  10. 临床路径论文、系统及其他资料汇总【88个】【第一辑】