nodyguy
Supreme Member
- Feb 8, 2012
- 1,344
- 544
Hi guys Im learning webrequests and I have a problem logging into google account.
First I click "Make Request" and then I click see code to see how the html would look like in a webbrowser and it says I have cookies disabled..
My App:
Here is my code :
First I click "Make Request" and then I click see code to see how the html would look like in a webbrowser and it says I have cookies disabled..
My App:
Here is my code :
Code:
Imports System.Net
Imports System.Text
Imports System.IO
Public Class Form1
Dim logincookie As CookieContainer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim postData As String = "GALX=wWuDJOaiIOg&continue=https%3A%2F%2Fwww.google.co.il%2F%3Fgws_rd%3Dcr%26ei%3Dw1XtUpPOHeLo4gTuq4GwCQ%26authuser%3D0&hl=en&_utf8=%E2%98%83&bgresponse=%21A0J7g8jYeZLzYETHWkGePyCNzQIAAAAXUgAAAAQqAOerAuj6CJFAwz1LOfLPLnp_tShLUn0R8h05q813-0vYwSD-aSMroEgro6AQkLxHnyjbwCO8p86e1gei1w4CNJCTGwTxhcIf9hCVb9Gbwfce-WuzkfXpA5SOVdKayNMoLvXzwBvBK8kqskQW4tpRDZKlbyHlmjI5CKIQapG3Vy-BTcOm66IxQUQy6hnF131k-KtKLYPSQSqM6OG5_KzbtmJJUXoCP1wa9XMOfAisQoFb88I5U7QqkmPIOdLFVnf1NgHiSWinvHgMVCxPC0-xWnQd-CfJ5Q-OWYKFcMZI5OfUMcqu0-QHIFM&pstMsg=1&dnConn=&checkConnection=youtube%3A165%3A1&checkedDomains=youtube&Email=" & TextBox1.Text & "&Passwd=" & TextBox2.Text & "&signIn=Sign+in&rmShown=1"
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://accounts.google.com/ServiceLoginAuth"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.Referer = "http://accounts.google.com/ServiceLoginAuth"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length
Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
RichTextBox1.Text = thepage
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.DocumentText = RichTextBox1.Text
End Sub
End Class