大家好,我在互联网上找到了一个可以登录 facebook 的脚本,这很好用,但现在我尝试在另一个网站上登录,但出现 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 来获得更好的错误消息,但从未使用过这个。我还在互联网上读到了一些错误是因为网站是内置 asp 而不是 .net 这是真的吗?
所有帮助表示赞赏