zoukankan      html  css  js  c++  java
  • 四级、六级查询系统研究

           3月3日晚上,因为四级考试没过,同学的准考证又找不到了,所以我就都在研究99宿舍的CET查询系统,希望能帮我同学找到他的分数,研究了一晚上虽然有点头绪了,但是始终没有C#写出查询软件(可能是我水平不够的原因吧)!

    ---------------------------

           分析了下99宿舍CET查询系统的源码,发现它是把数据提交到http://cet.99sushe.com/res/js/getscore.htmlhttp://cet.99sushe.com/getscore.html上面,提交的方式(下面列出99宿舍JavaScript的关键代码,非C#)

    代码
    1 //提交数据的代码
    2   var ajax = new Ajax();
    3 var param = "id=" + tid + "&vc=novcversion";
    4 ajax.Post("http://cet.99sushe.com/res/js//getscore.html",param , search_callback);
    5
    6  //callback的代码
    7  function search_callback(success, responsetext) {
    8 if (success) {
    9 score = responsetext;
    10 if (score.length > 15) {
    11 var sn = score.split(',')[5];
    12 if (netschoolname != sn) {
    13 netschoolname = sn;
    14 setTimeout("net_test('"+netschoolname+"')",3000);
    15 }
    16 }
    17 //showscore(score);
    18   }
    19 else {
    20 score = "-1";
    21 }
    22 }
    23 这里是POST的方法
    24 Ajax.prototype.Post = function(url, param, callback) {
    25 var xmlHttp = Ajax.prototype.GetHttpRequestObject();
    26 if (xmlHttp == null) {
    27 alert("create ajax error");
    28 return;
    29 }
    30 xmlHttp.onreadystatechange = function() {
    31 if (xmlHttp.readyState == RS_COMPLETE) {
    32 if (xmlHttp.status == 200) callback(true, xmlHttp.responseText);
    33 else callback(false, xmlHttp.responseText);
    34 xmlHttp = null;
    35 }
    36 }
    37 xmlHttp.open("POST", url, true);
    38 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=gb2312');
    39 xmlHttp.send(Ajax.prototype.EncodeUrlParam(param));
    40 }
    41
    42 //下面是EncodeUrlParam方法
    43 Ajax.prototype.EncodeUrlParam = function(param){
    44 var params = param.split('&');
    45 var rp = "";
    46 for(var i = 0;i< params.length;i++){
    47 var nv = params[i].split('=');
    48 if(rp != "") rp += "&";
    49 rp += nv[0] + "=";
    50 rp += encodeURIComponent(nv[1]);
    51 }
    52 return rp;
    53 }

    上面URL的部分应该就是上文提到的2个地址, 但是我用C#写的代码(关键代码如下)提交上去老是出现417错误,希望高手教教我怎么解决,谢谢!

    代码
    1 // 要提交表单的URI字符串。
    2 string uriString = "http://cet.99sushe.com/getscore.html";
    3 // 要提交的字符串数据。
    4 string postString = "id=351030092132901&vc=novcversion";
    5 // 初始化WebClient
    6 WebClient webClient = new WebClient();
    7 webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded;charset=gb2312");
    8 // 将字符串转换成字节数组
    9
    10 byte[] postData = Encoding.ASCII.GetBytes(postString);
    11 // 上传数据,返回页面的字节数组
    12 byte[] responseData = webClient.UploadData(uriString, "get", postData);
    13 // 返回的将字节数组转换成字符串(HTML)
    14 string srcString = Encoding.UTF8.GetString(responseData);

    记得以前有人写过批量查询软件,是用curl 工具构造相应的Referer请求和Post方法去查询成绩,命令行:curl http://cet.99sushe.com/getscore.html -e http://cet.99sushe.com/  -d id=准备证号 -d vc=novcversion http://cet.99sushe.com/getscore.html  但是我试过了好像已经不行了,不知道是不是操作错误!希望高手们提点下!

  • 相关阅读:
    Sliverlight之 矢量绘图
    Silverlight之 xaml布局
    七天学会ASP.NET MVC(七)——创建单页应用
    MVC视图之间调用方法总结
    C#取得程序的根目录以及判断文件是否存在
    七天学会ASP.NET MVC (六)——线程问题、异常处理、自定义URL
    [C#] .NET4.0中使用4.5中的 async/await 功能实现异步
    C#中StreamReader读取中文文本出现乱码的解决方法
    七天学会ASP.NET MVC (五)——Layout页面使用和用户角色管理
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/cracker/p/cet_study.html
Copyright © 2011-2022 走看看