求教 模拟post请求 public static CookieContainer loginCookie = new CookieContainer();内容太长了,没人看么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是不是有登录操作,你看firefox,应该有cookie你没传cookie *****************************************************************************签名档: http://feiyun0112.cnblogs.com/ 有登陆操作 private string GetLoginData(string url) { string respHtml=null; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.ContentType = "application/x-www-form-urlencoded"; request.UserAgent ="Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)"; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; //request.Referer = server; request.Timeout = 4000; request.KeepAlive = true; request.CookieContainer = loginCookie; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); foreach (Cookie cookie in response.Cookies) { loginCookie.Add(cookie); } StreamReader myReader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")); respHtml = myReader.ReadToEnd().Replace("\r\n",""); response.Close(); response = null; myReader = null; return respHtml; } catch (WebException ex) { return respHtml = ex.ToString(); } }这个是登陆 把cookie存到一个容器里的 post请求的时候带上了这个容器我在做其他get请求的时候 都能返回正确的html代码 从提示来看,第二个已经正确提交了.但是由于提交的内容中存在问题或者缺少字段,造成 "类型“System.DBNull”的对象无法转换为类型“System.Int32”。" 对啊,我现在也困惑在这里 ,我GET其他页面都没问题,而且html解析我需要的内容我也做好了.这个post我都弄了好几天了 还是没弄好 有没有大神能远程帮助我我的QQ 35914052 在此谢过 InsertCourseStatus:function(CouserID,GradeId,objName,ObjType,ObjID,ObName,callback,context){return new ajax_request(this.url + '?_method=InsertCourseStatus&_session=rw','CouserID=' + enc(CouserID)+ '\r\nGradeId=' + enc(GradeId)+ '\r\nobjName=' + enc(objName)+ '\r\nObjType=' + enc(ObjType)+ '\r\nObjID=' + enc(ObjID)+ '\r\nObName=' + enc(ObName),callback, context);},看看原始信息,他发的参数好像不是用&,是用\r\n连接 我试试谢谢 大神 已正确返回 OK您好,可以教學一下嗎?我也遇到這個問題了,我是用apache http的套件 有人能帮我把下面的C++代码编译成C#可以用的DLL吗,谢谢! C#如何读取EXCEL透视表原始数据 记得有个系统命令,可以查看全盘的文件结构,谁记得? 有一个问题,请问这样的功能怎么实现了 c# .net(winform)中定义了水晶报表问题 如何在调用控制台程序的时候不显示窗口 能帮忙看看这是什么问题啊 用户sa登陆失败(在线等)!!! 如何用手机利用US发短信 求指教 一运行到socket.revice 就自动退出 混合赋值问题 C#如何显示带am/pm的时间?
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
有登陆操作 private string GetLoginData(string url)
{
string respHtml=null; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent ="Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
//request.Referer = server;
request.Timeout = 4000;
request.KeepAlive = true;
request.CookieContainer = loginCookie; try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
foreach (Cookie cookie in response.Cookies)
{
loginCookie.Add(cookie);
}
StreamReader myReader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
respHtml = myReader.ReadToEnd().Replace("\r\n",""); response.Close();
response = null;
myReader = null; return respHtml;
}
catch (WebException ex)
{
return respHtml = ex.ToString();
}
}
这个是登陆 把cookie存到一个容器里的 post请求的时候带上了这个容器
我在做其他get请求的时候 都能返回正确的html代码
对啊,我现在也困惑在这里 ,我GET其他页面都没问题,而且html解析我需要的内容我也做好了.
这个post我都弄了好几天了 还是没弄好
有没有大神能远程帮助我我的QQ 35914052 在此谢过
谢谢 大神 已正确返回 OK
您好,可以教學一下嗎?我也遇到這個問題了,我是用apache http的套件