使用 WebBrowser cookie 的 c# WebRequest
我正在使用 WebBrowser 登录网站,然后我想使用正则表达式来获取一些数据,但是 webRequest 没有使用 web Browse cookie,
我的 webBrowser 是公开的, 有什么方法可以在 webRequest 中使用 WebBrowser cookie 吗?
I am logging into a site using a WebBrowser, then i want use regex to get some data , but webRequest didnt use web Browse cookie ,
my webBrowser is in public ,
is there any way to using WebBrowser cookie in webRequest ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这适用于大多数网站,但使用子域的网站可能会出现问题。
This will work on most sites, however sites that use subdomains might be a problem.
您可以将 CookieContainer 用于 Web 请求。
希望这可以帮助。
好的,您想要登录。那是不同的故事。 您可以使用 NetworkCredential 来实现这一点。
...
You can use a CookieContainer for a Webrequest.
Hope this helps.
Ok, you want to do a log in. Thats is different story. You can use NetworkCredential for that.
...
这是银光吗?
如果是这样,从 silverlight 3 开始,如果您使用浏览器网络堆栈,那么您应该免费获得 cookie。 默认情况下,当您使用 WebRequest.Create() 方法创建 HttpWebrequest 时,您会获得浏览器堆栈。 请注意,如果您使用 CreateHTTP 方法,您将获得一个客户端堆栈,默认情况下该堆栈不包含浏览器 cookie(您必须采取欺骗手段才能获取它们,如前所述)
请参阅 http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx关于 silverlight 自版本 3 以来的网络堆栈
is this silverlight?
if so, since silverlight 3 if you use the browser network stack than you should get cookies for free. By default you get the browser stack when you create n HttpWebrequest using the WebRequest.Create() method. note if you use CreateHTTP method, you get a client stack, which does not include browser cookies by default (you have to do trickery to get them, as described previously)
see http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx about the network stacks in silverlight since version 3