如何使用WebClient登录? [英] How to login using WebClient?

查看:390
本文介绍了如何使用WebClient登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我搜索了Google如何使用webclient登录来从访问者那里下载一些隐藏的内容...得到了代码但它不起作用:

Hey I've searched Google on how to login using webclient to download some hidden content from visitors... got the code but it isn't working :

httpclient = New WebClient
Dim loginInfo As New Specialized.NameValueCollection
loginInfo.Add("loginLogin", "username")
loginInfo.Add("loginPass", "password")
httpclient.UploadValues("http://www.goodfon.su/user/enter.php", "POST", loginInfo)

AddHandler httpclient.DownloadFileCompleted, AddressOf Downloaded
httpclient.DownloadFileAsync(New Uri("Link of image to download..."), ("C:\Desktop\Test.jpg"))





当试图下载USERS ONLY内容时,它会给出错误403 ..禁止。意味着登录无效,我正在尝试为该网站制作一个下载程序。注意:隐藏内容是来自色情目录的图像,它们仅供用户使用...并且它是免费的。



When trying to download "USERS ONLY" content it gives error 403.. Forbidden. Means login isn't working, I'm trying to make a downloader for that site. Note: hidden content are images from erotic catalog, and they are available only to users... and its free.

推荐答案

取决于什么类型的Web服务goodfon。 su has,必须简单的身份验证是WebClient在登录后获得cookie容器。



cookie容器必须附加到你正在制作的每个Web请求上to goodfon.su,现在goodfon.su知道你已经登录了。



看看 CookieContainer [ ^ ] class



Depending on what type of web service goodfon.su has, the must simple authentication is that the WebClient gets a cookie container in return after login.

The cookie container has to be attached to every web request you are making to goodfon.su, now goodfon.su knows that you are logged on.

Take a look at the CookieContainer[^] class

...
CookieContainer _sessionCookie = new CookieContainer();
...

// Login request
WebClient webRequest = new WebClient()
webRequest.CookieContainer = _sessionCookie;
webRequest.UpdateDataValue(...)


// Download image
WebClient webDownload = new WebClient();
webDownload .CookieContainer = _sessionCookie;
webDownload.DownloadFile(...);


...


这篇关于如何使用WebClient登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆