Читал, пробовал по разному, установил Fiddler. Получилось такое:
- Код: Выделить всё
Imports System.Text
Imports System.IO
Imports System.Net
Module Module1
Dim myHttpWebResponse As HttpWebResponse
Dim lang As String = "ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"
Dim chs As String = "windows-1251,utf-8;q=0.7,*;q=0.3"
Dim encod As String = "gzip,deflate,sdch"
Dim sCookies As String = ""
Dim sQueryString As String = "ret_path=nid%2F172016&login=myTestlogin&password=pass"
Sub Main()
Dim myHttpWebRequest As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://greenmama.ru"), HttpWebRequest)
myHttpWebRequest.Proxy = New WebProxy("127.0.0.1", 8888)
myHttpWebRequest.Method = "GET"
myHttpWebRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
myHttpWebRequest.Accept = "*/*"
myHttpWebRequest.Headers.Add("Accept-Encoding", encod)
myHttpWebRequest.Headers.Add("Accept-Language", lang)
myHttpWebRequest.Headers.Add("Accept-Charset", chs)
myHttpWebRequest.AllowAutoRedirect = False
myHttpWebRequest.CookieContainer = New System.Net.CookieContainer()
myHttpWebResponse = DirectCast(myHttpWebRequest.GetResponse, HttpWebResponse)
'Fiddler - результат 302
myHttpWebRequest = DirectCast(HttpWebRequest.Create("http://greenmama.ru"), HttpWebRequest)
myHttpWebRequest.Proxy = New WebProxy("127.0.0.1", 8888)
myHttpWebRequest.Method = "POST"
myHttpWebRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
myHttpWebRequest.Accept = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
myHttpWebRequest.Headers.Add("Accept-Encoding", encod)
myHttpWebRequest.Headers.Add("Accept-Language", lang)
myHttpWebRequest.Headers.Add("Accept-Charset", chs)
Dim ByteArr As Byte() = Text.Encoding.GetEncoding(1251).GetBytes(sQueryString)
myHttpWebRequest.ContentLength = ByteArr.Length()
myHttpWebRequest.GetRequestStream().Write(ByteArr, 0, ByteArr.Length)
'На следующей строке часто: The operation has timed out
myHttpWebResponse = DirectCast(myHttpWebRequest.GetResponse(), HttpWebResponse)
'Fiddler - результат 302
'Тут как я понял нужно перейти на целевую страницу ?
myHttpWebRequest = DirectCast(HttpWebRequest.Create("http://greenmama.ru"), HttpWebRequest)
myHttpWebRequest.Proxy = New WebProxy("127.0.0.1", 8888)
myHttpWebRequest.Referer = "http://greenmama.ru"
myHttpWebRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0"
myHttpWebRequest.Accept = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
myHttpWebRequest.Headers.Add("Accept-Encoding", encod)
myHttpWebRequest.Headers.Add("Accept-Language", lang)
myHttpWebRequest.Headers.Add("Accept-Charset", chs)
myHttpWebRequest = DirectCast(HttpWebRequest.Create("http://greenmama.ru"), HttpWebRequest)
'Fiddler - результат 200
End Sub
End Module
Подскажите пожалуйста, что мне нужно поправить.
Заранее благодарен.