Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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 :
VB
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"))


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.
Posted

1 solution

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

C#
...
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(...);


...
 
Share this answer
 
v4
Comments
Boudi AlSayed 15-Aug-14 3:53am    
Ok nice, is there anyway to copy webbrowser(winforms control) cookie to HttpWebRequest?
Kim Togo 15-Aug-14 4:14am    
You create a new CookieContainer and attached it to every webrequest. See solution.
Boudi AlSayed 15-Aug-14 5:19am    
Did that, but im still getting error about image doesn't exist... I've copied WebBrowser cookies which ive signed in with it to the Site.. and copied the cookies to the HttpWebRequest... but still have problem not getting image

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900