Du hast auch so eine Kugel?
War am Handy und konnte den Code da nicht schreiben :D
Code:
Imports System.Net
Imports System.Threading
Public Class frmMain
Public cookie As CookieContainer = New CookieContainer()
Public content As String
Private Sub lc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lc.Click
lc.Text = ""
End Sub
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
content = WebRPOST("http://de.board.bigpoint.com/darkorbit/login.php?do=login", "vb_login_username=" + username.Text + "&vb_login_password=" + pw.Text + "&s=&do=login&vb_login_md5password=&vb_login_md5password_utf=", cookie)
Thread.Sleep(3000)
content = WebRGET("http://de.board.bigpoint.com/darkorbit/index.php", cookie)
End Sub
End Class
HttpWebRequest Klasse:
Code:
Imports System.Net
Imports System.IO
Imports System.Text
Module HTTP
Public Function WebRPOST(ByVal sUrl As String, ByVal sPost As String, ByVal cookies As CookieContainer) As String
Try
Dim nRequest As HttpWebRequest = CType(WebRequest.Create(sUrl), HttpWebRequest)
nRequest.Method = "POST"
nRequest.CookieContainer = cookies
nRequest.ContentType = "application/x-www-form-urlencoded"
nRequest.Proxy = New WebProxy()
Dim nbyteArray() As Byte = Encoding.UTF8.GetBytes(sPost)
nRequest.ContentLength = nbyteArray.Length
Dim nDataStream As Stream = nRequest.GetRequestStream()
nDataStream.Write(nbyteArray, 0, nbyteArray.Length)
nDataStream.Close()
nRequest.KeepAlive = True
nRequest.AllowAutoRedirect = True
nRequest.PreAuthenticate = True
Dim nResponse As HttpWebResponse = nRequest.GetResponse()
nDataStream = nResponse.GetResponseStream()
Dim nreader As New StreamReader(nDataStream)
Dim nServerResponse As String = nreader.ReadToEnd()
nreader.Close()
nDataStream.Close()
nResponse.Close()
Return nServerResponse
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
End Function
Public Function WebRGET(ByVal sUrl As String, Optional ByRef cookies As CookieContainer = Nothing) As String
Static cookiecontainer As CookieContainer
Static cookiecoll As CookieCollection
Try
If (cookiecoll Is Nothing) Then
cookiecoll = New CookieCollection
End If
If (cookiecontainer Is Nothing) Then
cookiecontainer = New CookieContainer
End If
Dim req As HttpWebRequest = DirectCast(HttpWebRequest.Create(sUrl), HttpWebRequest)
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)"
req.Method = "GET"
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
req.Referer = "http://de.board.bigpoint.com/darkorbit/login.php?do=login"
req.KeepAlive = True
req.CookieContainer = New CookieContainer()
req.CookieContainer = cookiecontainer
req.CookieContainer.Add(cookiecoll)
req.Proxy = New WebProxy()
Dim response As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(response.GetResponseStream())
Dim html As String = sr.ReadToEnd()
sr.Close()
response.Close()
Return html
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
End Function
Hoffe, ihr habt eine Lösung^^
Vllt sagt deine Kristallkugel mehr :)
MfG