社区
C#
帖子详情
关于HttpWebRequest的问题
bupo_007
2008-03-20 11:22:00
我想写一个登陆学校图书馆的程序获,取借阅信息
登陆图书馆需要用户名和密码
string url2 = "http://59.64.144.2/reader/infoList.jsp";//登陆页面的连接
怎么用密码和用户名参数登陆呢
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
这句中是什么意思
...全文
102
4
打赏
收藏
关于HttpWebRequest的问题
我想写一个登陆学校图书馆的程序获,取借阅信息 登陆图书馆需要用户名和密码 string url2 = "http://59.64.144.2/reader/infoList.jsp";//登陆页面的连接 怎么用密码和用户名参数登陆呢 myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"; 这句中是什么意思
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
bupo_007
2008-03-21
打赏
举报
回复
每人帮帮忙吗
谢了大牛们!
bupo_007
2008-03-20
打赏
举报
回复
还有我还想调用网页上的图书检索功能,不知能否实现
怎么实现呢
bupo_007
2008-03-20
打赏
举报
回复
string url = "http://59.64.144.2/reader/login.jsp?str_kind=login";
string url2 = "http://59.64.144.2/reader/infoList.jsp";
string indata = "barcode=" + user + "&password=" + psw;
string outdata = "";//return string
CookieContainer myCookieContainer = new CookieContainer();
//新建一个CookieContainer来存放Cookie集合
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
//新建一个HttpWebRequest
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
myHttpWebRequest.ContentLength = indata.Length;
myHttpWebRequest.Method = "POST";
myHttpWebRequest.CookieContainer = myCookieContainer;
//设置HttpWebRequest的CookieContainer为刚才建立的那个myCookieContainer
Stream myRequestStream = myHttpWebRequest.GetRequestStream();
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
myStreamWriter.Write(indata);
//把数据写入HttpWebRequest的Request流
myStreamWriter.Close();
myRequestStream.Close();
//关闭打开对象
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
//新建一个HttpWebResponse
myHttpWebResponse.Cookies = myCookieContainer.GetCookies(myHttpWebRequest.RequestUri);
//获取一个包含url的Cookie集合的CookieCollection
Stream myResponseStream = myHttpWebResponse.GetResponseStream();
//StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("gb2312"));
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.Default);
outdata = myStreamReader.ReadToEnd();
//把数据从HttpWebResponse的Response流中读出
myStreamReader.Close();
myResponseStream.Close();
//显示"登录"
//拿到了Cookie,再进行请求就能直接读取到登录后的内容了
myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url2);
myHttpWebRequest.CookieContainer = myCookieContainer;//*
//刚才那个CookieContainer已经存有了Cookie,把它附加到HttpWebRequest中则能直接通过验证
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Cookies = myCookieContainer.GetCookies(myHttpWebRequest.RequestUri);
myResponseStream = myHttpWebResponse.GetResponseStream();
//myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("gb2312"));
myStreamReader = new StreamReader(myResponseStream, Encoding.Default);
outdata = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
//Console.WriteLine(outdata);
return outdata;
}
这是别人写的代码,其中
string indata = "barcode=" + user + "&password=" + psw;
barcode和&passwords是怎么来的呢?
珍惜生命远离CPP
2008-03-20
打赏
举报
回复
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
URL编码,也就是你提交的数据内容编码
你需要使用POST的方式提交你的用户名密码。
火车头7.6版采集https插件:网站报错System.Net.
HttpWebRequest
问题
解决方案
在这个场景下,我们遇到了一个特定的
问题
——"System.Net.
HttpWebRequest
"错误,这是在火车头7.6版本中进行HTTPS采集时可能会遇到的一个常见
问题
。下面将详细介绍这个
问题
的原因、解决方案以及提供的插件。 首先,`...
HttpWebRequest
###
HttpWebRequest
:深入理解与应用 #### 知识点一:
HttpWebRequest
的初始化与使用 在.NET框架中,`
HttpWebRequest
`是`WebRequest`类的一个具体实现,专门用于处理HTTP和HTTPS请求。为了正确地使用`...
C#中
HttpWebRequest
介绍
HttpWebRequest
request = WebRequest.Create(url) as
HttpWebRequest
; // 设置请求方式为GET request.Method = "GET"; // 设置默认的用户代理信息 request.UserAgent = DefaultUserAgent; if (!string....
c#
httpwebrequest
调用webservice demo
需要注意的是,在实际开发中,还需要考虑异常处理、安全性等
问题
。此外,随着技术的发展,RESTful服务逐渐成为主流,SOAP服务的使用场景正在减少。但对于某些遗留系统或者特定需求而言,掌握SOAP调用仍然是很有必要...
httpwebrequest
httpwebrequest
封装类
C#
111,095
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章