c# - logged in to PureVolume.com programatically ! -
I tried several ways, but purevolume.com program !!!
Login URLs failed to login.
Try it out to anyone and provide sample code to achieve this goal
After "div class =" text "itemprop =" text ">
, stream back (var stream = new StreamReader (webResponse.GetResponseStream ())). Use of ReadToEnd () Something like this should be done ... you need to post an http and send your username and password. To remain "logged in" you need a cookie container, which you re-use for all other requests again.
EDIT: The verification code which was tested was required initial GET request to login / session session before login to POST. I also make it similar to a "normal" request from a browser Has added some HTTP headers for.
Zero main () {// We need a container to store cookies in. CookieContainer Cookies = New Cookie Container (); // Request a login to receive a session cookie GETHML ("http://www.purevolume.com/login", cookies); // Now we can login login ("some user name", "some-password", cookies); } Public bool log (string username, string password, cookieContainer cookies) {string poststring = String.Format ("user name = {0} & password = {1} & user_login_button.x = 63 & amp; User_login_button.y = 13 & amp; user_login_button = Login ", username, password); Byte [] PostData = Encoding. UTF8.GetBytes (PostString); HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create ("http://www.purevolume.com/login"); WebRequest.CookieContainer = Cookies; WebRequest.method = "post"; WebRequest.Referer = "http://www.purevolume.com/login"; WebRequest.Headers.Add ("original", "http://www.purevolume.com"); webRequest.UserAgent = "Mozilla / 4.0 (compatible; MSIE 7.0, Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022,"; webRequest.ContentType = "application / x-www -form-urlencoded "; webRequest.ContentLength = using postdata.Length; (stream author = webRequest.GetRequestStream ()) using writer.Write (POSTDATA, 0, postdata.Length); (HttpWebResponse WebResponse = (HttpWebResponse) webRequest.GetResponse ()) {// we need to add any feedback cookies to your cookie container cookies.Add (webResponse.Cookies); // debug only using (var stream = new StreamReader (webResponse.GetResponseStream ( For))) System.Diagnostics.Debug .WriteLine (stream.ReadToEnd ()); Return (webResponse.StatusCode = = HttpStatusCode.OK);}} Public string GETHtml (string URL, CookieContainer cookies) {HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create; webRequest.Cookie Container = Cookies; webRequest.Us ErAgent = "Mozilla / 4.0 (compatible ; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022, "; webRequest.Referer =" http://www.purevolume.com/login "; (HttpWebResponse WebResponse = (HttpWebResponse) using webRequest.GetResponse ()) {// we add any feedback need cookies to our Cookie container cookies.Add (webResponse.Cookies);}}
Comments
Post a Comment