c# 接受响应无法接收到html,而用python就可以。

qq_34378352 2016-10-31 10:07:15
用python和c#做一样的事情,抓包看是同样的请求。但是c#的response没有html。
有点迷惑,是c#自动滤过了html相关的东西吗?求解!!!

private void PostLogout(object sender, RoutedEventArgs e)
{
CookieContainer cc = GetJSESSIONID();
HttpWebRequest request = null;
HttpWebResponse response = null;
try
{
string Url = "http://service2.swu.edu.cn/selfservice/module/webcontent/web/onlinedevice_list.jsf";
request = (HttpWebRequest) WebRequest.Create(Url);

request.Method = "GET";
request.Host = "service2.swu.edu.cn";
request.KeepAlive = true;
request.Headers.Add("Upgrade-Insecure-Requests: 1");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64)";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
request.Headers.Add("Accept-Encoding: gzip, deflate, sdch");
request.Headers.Add("Accept-Language: zh-CN,zh;q=0.8");
request.Headers.Add("DNT: 1");
request.CookieContainer = cc;

response = (HttpWebResponse) request.GetResponse();

Stream ResponseStream = response.GetResponseStream();
StreamReader StreamReader = new StreamReader(ResponseStream);
string retString = StreamReader.ReadToEnd();

string RegexStr =
@"<input[/s]id=""[/S]+?5e46ff2b57b349f90157c2dc05be366e0""[/S/s]+?value=""([/S]+?)""[/S/s]+?value=""([/S]+?)""[/S/s]+?value=""([/S]+?)""[/S/s]+?id=""creatTime[/S/s]+?value=""([/S/s]+?)""";
Match mat = Regex.Match(retString, RegexStr);

textBox1.AppendText(mat.Groups[1].Value);
textBox1.AppendText(retString);

request.Abort();
response.Close();
StreamReader.Close();

}
catch (WebException ex)
{
MessageBox.Show(ex.Message, string.Format("出错"));
}
}

...全文
186 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_34378352 2016-10-31
  • 打赏
  • 举报
回复
还有很多相似的<input>就省略了 以下是缺失的<html> <html> <head> <title>校园网自助服务系统</title> <link href="/selfservice/common/self/css/common_hk.css" type="text/css" rel="stylesheet"> <link href="/selfservice/module/webcontent/css/onlinedevice_list.css" type="text/css" rel="stylesheet"> <script language="javascript" src="/selfservice/common/self/js/jquery-1.8.0.js" type="text/javascript"></script> <script language="javascript" src="/selfservice/common/self/js/common.js" type="text/javascript"></script> <script language="javascript" src="/selfservice/common/self/js/calendar.js" type="text/javascript"></script> <script language="javascript" src="/selfservice/module/webcontent/js/onlinedevice_list.js" type="text/javascript"></script> <style> @media print { .btn { display: none; } .btn2 { display: none; } } </style> </head> <body onkeydown="keyDownDeal();" oncontextmenu="return true" style="align-text: center; margin: 0px; padding: 0px; background: #f7f9fa;"> <input type="hidden" name="onlinedevicelistjs_tip1" id="onlinedevicelistjs_tip1" value="修改失败"/> <input type="hidden" name="onlinedevicelistjs_tip2" id="onlinedevicelistjs_tip2" value="我的设备"/> <input type="hidden" name="onlinedevicelistjs_tip3" id="onlinedevicelistjs_tip3" value="我的设备"/> <input type="hidden" name="onlinedevicelistjs_tip4" id="onlinedevicelistjs_tip4" value="上线时间 :"/> <input type="hidden" name="onlinedevicelistjs_tip5" id="onlinedevicelistjs_tip5" value="关闭失败"/> <input type="hidden" name="onlinedevicelistjs_tip6" id="onlinedevicelistjs_tip6" value="您已选中"/> <input type="hidden" name="onlinedevicelistjs_tip7" id="onlinedevicelistjs_tip7" value="条绑定信息"/> <input type="hidden" name="onlinedevicelistjs_tip8" id="onlinedevicelistjs_tip8" value="至少选择一条信息进行解绑"/> <div style="text-align: center; margin: 0px; padding: 0px; background: #f7f9fa;"> <input id="userId" type="hidden" name="userId" value="qw929587157" /> <input type="hidden" name="_id15" value="0" /> <input type="hidden" name="_id16" value="true" /> <input id="bl" type="hidden" name="bl" value="true" /> <input id="terminalMacBindInfoBeaninit" type="hidden" name="terminalMacBindInfoBeaninit" value="" /> <input id="terminalMacBindInfoBeantimeOut" type="hidden" name="terminalMacBindInfoBeantimeOut" value="false" /> <div style="margin: 0 auto; width: 95%;"> <div style="width: 100%; height: 56px; font-size: 24px; line-height: 46px; text-align: left;">我的设备</div> <div style="width: 100%; height: 45px; text-align: left; background: #F7F9FA;"> <div style="width: 35%; height: 35px; margin-top: 10px; font-size: 18px; text-align: left; float: left;" id="after"></div> <div style="float: right;width:60%;text-align:right;" id="mydiv1"> <input id="butsub1" style="display: none;margin-right:5px;" type="button" class="butsubmit" onmouseover="this.className='butsubmitOver'" onmouseleave="this.className='butsubmit'" onmousedown="this.className='butsubmitClicked';" value="下一步" onclick="checkUnbind2();" > <input id="butsub2" style="display: none;" type="button" class="butsubmit" onmouseover="this.className='butsubmitOver'" onmouseleave="this.className='butsubmit'" onmousedown="this.className='butsubmitClicked';" onclick="cancelSelect2();" value="取消" > </div> </div> <div style="font-size: 1px; border-bottom: 1px solid; width: 100%; height: 1px;"></div> <div id="mydiv" style="display: block;"> <div style="width: 100%; height: 76px;border-bottom: 1px solid #cccccc;" id="divdiv5e46ff2b57b349f90157c2dc05be366e0"> <table border="0" width="100%"> <tr> <td width="10%" height="76px;" align="left"><div> <img title="个人电脑" src="../img/a7.png" /> </div></td> <td width="49%" align="left"> <input id="inputId5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value="我的设备"> <input id="userIp45e46ff2b57b349f90157c2dc05be366e0" type="hidden" value="10.126.23.33"> <input id="usermac5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value="086266B3C0E3"> <input id="devicenameuuid5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value=""> <input id="systemtype5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value=""> <input id="devicetype5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value=""> <input id="createTimeStr5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value="10-31 21:44:54"> <input id="inputrow5e46ff2b57b349f90157c2dc05be366e0" type="hidden" value="我的设备"> <div id="divId5e46ff2b57b349f90157c2dc05be366e0" class="devicelabel" style="margin-top:2px; width: 300px; height:48px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> <label id="5e46ff2b57b349f90157c2dc05be366e0" class="lablesub" onclick="showchangename('5e46ff2b57b349f90157c2dc05be366e0',1)" title="我的设备" style="cursor: pointer; outline: none; font-family: Microsoft YaHei; font-size: 18px; -moz-user-select: none;" onselectstart="return false"> 我的设备 </label> <span style="width: 5px;"></span><span onclick="showchangename('5e46ff2b57b349f90157c2dc05be366e0',1)" style="cursor:pointer;"><img src="../img/cc1.png"></span><br/> <span style="font-size:12px;color:#939495;margin-top:2px;height:14px;">上线时间 : 10-31 21:44:54</span><span style="width: 5px;"> </span><span id="bb5e46ff2b57b349f90157c2dc05be366e0" onclick="showspan('5e46ff2b57b349f90157c2dc05be366e0');" style="cursor: pointer;"><img src="../img/a4.png"></span><br/> <span id="aa5e46ff2b57b349f90157c2dc05be366e0" style="display: none;font-size:12px;color:#939495;margin-top:6px;"> <span id="a2">MAC : <span id="a2mac">086266B3C0E3</span>    </span> <span id="a1">IP : 10.126.23.33</span > </span> </div> <script type="text/javascript"> /* testAuto(''); */ </script> </td> <td width="41%"> <div style="float: right; height: 34px"> <input type="button" value="下线" class="xia1" onmouseover="this.className='xiaOver1'" onmouseleave="this.className='xia1'" onmousedown="this.className='xiaClicked1';" onclick="offline('5e46ff2b57b349f90157c2dc05be366e0');"/> </div> </td> <!-- </td>--> </tr> <tr> <td colspan="4"> <div id="errorTd5e46ff2b57b349f90157c2dc05be366e0" style="display: none"> <div style="height: 22; width: 21px; float: left; margin-top: 3px; margin-left: 3px;"> <img src="/selfservice/common/self/img/errorTip.png"> </div> <div style="height: 22px; margin-top: 4px; float: left; margin-left: 10px; background-color: #F9F4D5;"> <label id="error5e46ff2b57b349f90157c2dc05be366e0" class="errorMessage" style="color: #333333; font-size: 16px">禁止设备名 称超过64个字节</label> </div> </div> </td> </tr> <!-- <tr> <td colspan="4"><div style="font-size: 1px; border-bottom: 1px solid #cccccc; width: 100%; height: 1px;"> </div></td> </tr> --> </table> ...........字数限制省略一部分 </div> <form id="UserOperationForm" method="post" action="/selfservice/module/webcontent/web/onlinedevice_list.jsf" onkeydown="common.checkEnter(this);" enctype="application/x-www-form-urlencoded" style="margin: 0px; padding: 0px;"> <input id="UserOperationForm:selectedUuid" type="hidden" name="UserOperationForm:selectedUuid" /> <input id="UserOperationForm:selectedUuid2" type="hidden" name="UserOperationForm:selectedUuid2" value="" /> <input type="hidden" name="com.sun.faces.VIEW" id="com.sun.faces.VIEW" value="_id64498:_id64499" /><input type="hidden" name="UserOperationForm" value="UserOperationForm" /> <script type="text/javascript"> <!-- function clearFormHiddenParams_UserOperationForm(curFormName) { var curForm = document.forms[curFormName]; } //--> </script> </form> </div> </div> </body> </html>
qq_34378352 2016-10-31
  • 打赏
  • 举报
回复
下面是返回的: <input type="hidden" value='false' id="_sys_is_international"> <input type="hidden" value='列数必须为整数' id="changeTableColspanjs_tip1"> <input type="hidden" value='是否确定要删除本条数据?' id="packageflowctrlconfigjs_tip1"> <input type="hidden" value='是否确定要删除选中的运营商对接配置?' id="common_managerjs_tip1"> <input type="hidden" value='操作正在进行中,请稍候...' id="common_managerjs_tip2"> <input type="hidden" value="被浏览器拒绝! 请在浏览器地址栏输入'about:config'并回车 然后将'signed.applets.codebase_principal_support'设置为'true'" id="common_managerjs_tip3"> <input type="hidden" value='请先选择要处理的数据!' id="common_selfjs_tip1"> <input type="hidden" value='执行此操作' id="common_selfjs_tip2"> <input type="hidden" value='是否确定要' id="common_selfjs_tip3"> <input type="hidden" value='高级查询' id="common_selfjs_tip4"> <input type="hidden" value='简单查询' id="common_selfjs_tip5"> <input type="hidden" value='已完成' id="eccn_managejs_tip1"> <input type="hidden" value='% ,共检索到' id="eccn_managejs_tip2"> <input type="hidden" value='条记录!' id="eccn_managejs_tip3"> <input type="hidden" value='正在停止...' id="eccn_managejs_tip4"> <input type="hidden" value='跳转页数只能是1!' id="eccn_managejs_tip5"> <input type="hidden" value='跳转页数只能是1至' id="eccn_managejs_tip6"> <input type="hidden" value='的整数!' id="eccn_managejs_tip7"> <input type="hidden" value='当前有导出正在执行,请稍后重试' id="eccn_managejs_tip8"> <input type="hidden" value='查询条件已经失效,请重新查询数据后再导出' id="eccn_managejs_tip9"> <input type="hidden" value='最多只能导出' id="eccn_managejs_tip10"> <input type="hidden" value='条数据!' id="eccn_managejs_tip11"> <input type="hidden" value='停止查询' id="eccn_managejs_tip12"> <input type="hidden" value='正在进行文档内容格式校验,请稍侯...' id="progressbarjs_tip1"> <input type="hidden" value='由于某些特殊原因导致上传的文件被损坏,无法继续进行当前操作,请重新进行导入操作。' id="progressbarjs_tip2"> <input type="hidden" value='已校验' id="progressbarjs_tip3"> <input type="hidden" value='已导入' id="progressbarjs_tip4"> <input type="hidden" value='正在进行数据导入,请稍侯...' id="progressbarjs_tip5"> <input type="hidden" value='绑定运营商' id="submenujs_tip1"> <input type="hidden" value='更改/解绑运营商' id="submenujs_tip2"> <input type="hidden" value='更改运营商账号' id="submenujs_tip3"> <input type="hidden" value='解绑运营商账号' id="submenujs_tip4"> <input type="hidden" value='全选' id="global_selectall"> <input type="hidden" value='全选 (注:不选择任何用户组表示可管理所有用户组)' id="manager_groupinfo_all"> <input type="hidden" value='数据装载中......' id="tabledatajs_tip1"> <input type="hidden" value='请输入结束时间' id="tabledatajs_tip2"> <input type="hidden" value='请输入开始时间' id="tabledatajs_tip3"> <input type="hidden" value='开始时间格式错误' id="tabledatajs_tip4"> <input type="hidden" value='结束时间格式错误' id="tabledatajs_tip5"> <input type="hidden" value='开始时间不得大于结束时间' id="tabledatajs_tip6"> <input type="hidden" value='保存成功!' id="astralfigure_ajax_tip1"> <input type="hidden" value='有线1X' id="astralfigure_color_tip1"> <input type="hidden" value='有线Web' id="astralfigure_color_tip2"> <input type="hidden" value='无线Web' id="astralfigure_color_tip3"> <input type="hidden" value='无线1X' id="astralfigure_color_tip4"> <input type="hidden" value='其他' id="astralfigure_color_tip5"> <input type="hidden" value='电脑' id="global_terminal_pc"> <input type="hidden" value='手机' id="global_terminal_phone"> <input type="hidden" value='平板电脑' id="global_terminal_pad"> <input type="hidden" value='无线移动终端' id="global_terminal_wirelessdevice"> <input type="hidden" value='每个区域最多 8 个顶点' id="astralfigure_edit_tip1"> <input type="hidden" value='最多只能包含16个字符!' id="astralfigure_edit_tip2"> <input type="hidden" value='只能包含中文、英文、数字、下划线' id="astralfigure_edit_tip3"> <input type="hidden" value='已有相同名称区域!' id="astralfigure_edit_tip4"> <input type="hidden" value='不能为空!' id="bace_validator_nasip_end_empty"> <input type="hidden" value='apMac不能超过32个字符' id="astralfigure_home_tip1"> <input type="hidden" value='不能包含字符<>\!' id="astralfigure_home_tip2"> <input type="hidden" value='多IP操作时只能使用一种方式进行添加' id="astralfigure_home_tip3"> <input type="hidden" value='上传成功!' id="astralfigure_home_tip4"> <input type="hidden" value='设备定位' id="devicemonitor_homejs_tip1"> <input type="hidden" value='设备所在区域' id="devicemonitor_homejs_tip2"> <input type="hidden" value='区域' id="devicemonitor_homejs_tip3"> <input type="hidden" value='不通' id="devicemonitor_homejs_tip4"> <input type="hidden" value='总设备数' id="devicemonitor_homejs_tip5"> <input type="hidden" value='人数' id="devicemonitor_homejs_tip6"> <input type="hidden" value='使用率' id="devicemonitor_homejs_tip7"> <input type="hidden" value='无法连通' id="devicemonitor_homejs_tip8"> <input type="hidden" value='次' id="devicemonitor_homejs_tip9"> <input type="hidden" value='设备类型:' id="devicemonitorlistbean_devicetype"> <input type="hidden" value='是否确定要删除该地图配置?' id="mapconfigjs_tip1"> <input type="hidden" value='地图正在被使用,不能删除!' id="mapconfigjs_tip2"> <input type="hidden" value='请选择文件!' id="mapconfigjs_tip3"> <input type="hidden" value='只能上传.xls 或 .xlsx格式文件!' id="mapconfigjs_tip4"> <input type="hidden" value='只能上传.png文件!' id="mapconfigjs_tip5"> <input type="hidden" value='是否确定要进行清空操作?' id="mapconfigjs_tip6"> <input type="hidden" value='请输入生效时间。' id="authcodejs_tip1"> <input type="hidden" value='请输入失效时间。' id="authcodejs_tip2"> <input type="hidden" value='输入生效时间大于等于失效时间。' id="authcodejs_tip3"> <input type="hidden" value='输入失效时间小于当前时间。' id="authcodejs_tip4"> <input type="hidden" value='请输入合适的使用人数。' id="authcodejs_tip5"> <input type="hidden" value='请输入适合的上网时长。' id="authcodejs_tip6"> <input type="hidden" value='请选择申请类型。' id="authcodejs_tip7"> <input type="hidden" value='请输入联系方式。' id="authcodejs_tip8"> <input type="hidden" value='请输入正确的手机号码或者电话。' id="authcodejs_tip9"> <input type="hidden" value='请输入合法URL。' id="authcodejs_tip10"> <input type="hidden" value='上网时长不能为空。' id="authcodejs_tip11"> <input type="hidden" value='请选择上网时长。' id="authcodejs_tip12"> <input type="hidden" value='请输入' id="authcodejs_tip13"> <input type="hidden" value='以内的上网时长。' id="authcodejs_tip14"> <input type="hidden" value='使用人数不能为空。' id="authcodejs_tip15"> <input type="hidden" value='以内的使用人数。' id="authcodejs_tip16"> <input type="hidden" value='输入失效时间必须大于当前时间。' id="authcodejs_tip17">

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧