Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void SubmitData()
- {
- try
- {
- string user = textBox1.Text;
- string pass = textBox2.Text;
- ASCIIEncoding encoding = new ASCIIEncoding();
- string postData = "username=" + user + "&password=" + pass + "&remember=remember&submit=&_jafo%5BactiveExperiments%5D=%5B%5D&_jafo%5BexperimentData%5D=%7B%7D";
- byte[] data = encoding.GetBytes(postData);
- string pageContent = null;
- WebRequest request = WebRequest.Create("https://imgur.com/signin");
- HttpWebResponse myres = (HttpWebResponse)request.GetResponse();
- request.Method = "POST";
- request.ContentType = "application/x-www-form-urlencoded";
- request.ContentLength = data.Length;
- Stream stream = request.GetRequestStream();
- stream.Write(data, 0, data.Length);
- stream.Close();
- WebResponse response = request.GetResponse();
- stream = response.GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- string final_reponse = sr.ReadToEnd();
- using (StreamReader sr2 = new StreamReader(myres.GetResponseStream()));
- {
- pageContent = this.ReadToEnd();
- }
- if (pageContent.Contains("logout"))
- {
- MessageBox.Show("Successful Login");
- }
- //Regex r = new Regex(@"Your login information was incorrect.");
- //Match m = r.Match(final_reponse);
- //Regex r2 = new Regex(@"logout");
- //Match m2 = r2.Match(final_reponse);
- //MessageBox.Show(m.Value);
- sr.Close();
- stream.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error: " + ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement