Facebookにログインできるスクリプトをインターネットで見つけましたが、これはうまく機能しますが、別のWebサイトでログインしようとすると、500エラーが発生します。
Dim cookieJar As New Net.CookieContainer()
Dim request As Net.HttpWebRequest
Dim response As Net.HttpWebResponse
Dim strURL As String = "http://xtract.basdistributie.nl:4040/Account/LogOn"
Try
request = Net.HttpWebRequest.Create(strURL)
request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
request.Method = "GET"
request.CookieContainer = cookieJar
response = request.GetResponse()
For Each tempCookie As Net.Cookie In response.Cookies
cookieJar.Add(tempCookie)
Next
'Send the post data now
request = Net.HttpWebRequest.Create(strURL)
request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
request.Method = "POST"
request.AllowAutoRedirect = True
request.CookieContainer = cookieJar
Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
writer.Write("username=???????&password=????????")
writer.Close()
response = request.GetResponse()
'Get the data from the page
Dim stream As StreamReader = New StreamReader(response.GetResponseStream())
Dim data As String = stream.ReadToEnd()
response.Close()
If data.Contains("BAS Distribution Xtract") = True Then
MsgBox("ingelogd")
End If
MsgBox(data)
Catch e As Exception
If TypeOf e Is WebException AndAlso DirectCast(e, WebException).Status = WebExceptionStatus.ProtocolError Then
Dim errResp As WebResponse = DirectCast(e, WebException).Response
' read the error response
Using respStream As Stream = errResp.GetResponseStream()
MsgBox(e.ToString)
End Using
End If
End Try
エラー メッセージは、response = request.GetResponse () の場所を見つけます。また、Fidler を使用してより適切なエラー メッセージを取得しようとしましたが、これを使用したことはありません。ウェブサイトが.net の代わりに asp に組み込まれている場合、これは True? です。
すべての助けに感謝