Dim postData As String = "username=" + TextBox1.Text + "&password=" + TextBox2.Text
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://www.instagram.com/accounts/web_create_ajax/?hl=en"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"
postReq.Referer = "https://www.instagram.com/?hl=fa"
postReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
' postReq.AutomaticDecompression = DecompressionMethods.GZip
postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
postReq.ContentLength = byteData.Length
' postReq.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
postReq.Headers.Add("Accept-Encoding", "gzip, deflate, br")
postReq.Headers.Add("Accept-Language", "en-US,en;q=0.8")
postReq.Headers.Add("Cookie", "mid=WIN3fQAEAAEIH0wUdSEJfTz_CkUY; ig_pr=1; ig_vw=1366; rur=ATN; csrftoken=UUT5JcCgCeS7dDPmEqRXxLiMaeQjYV9m")
' postReq.Headers.Add("Upgrade-Insecure-Requests", "1")
postReq.Headers.Add("x-csrftoken", "UUT5JcCgCeS7dDPmEqRXxLiMaeQjYV9m")
postReq.Headers.Add("x-requested-with", "XMLHttpRequest")
postReq.Headers.Add("x-instagram-ajax", "1")
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())
برچسب:
نویسنده: محمد رضا جوادیان