Click here to Skip to main content
12,242,460 members (53,768 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB WPF VB.NET
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"))


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 14-Aug-14 15:41pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

...
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 15 Aug 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100