title image


Smiley Re: VB2005 - Daten per Post an eine Seite senden und ergebnis auslesen
Zuerst habe ich es so per Sockets versucht:



Function post(ByVal server As String, ByVal file As String, ByVal values As ArrayList, ByVal ststart As String, ByVal ststop As String)



Try

connect(server)

Dim str, tmp, tmp2 As String

Dim i As Integer

Dim copy As Boolean

copy = False



tmp = ""

str = "POST /" & file & " HTTP/1.0" & vbCrLf '& vbCrLf

str &= "HOST: " & server & vbCrLf

str &= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1" & vbCrLf

str &= "Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & vbCrLf

str &= "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & vbCrLf

str &= "Accept(-Encoding) : gzip, deflate" & vbCrLf

str &= "Keep-Alive: 300" & vbCrLf

str &= "Content-Type: application/x-www-form-urlencoded" & vbCrLf



For i = 0 To values.Count - 1

tmp &= values(i)

tmp &= "=" & values(i + 1) & "&"

i += 1

Next



tmp = tmp.Substring(0, tmp.Length - 1)

str &= "Content-Length: " & tmp.Length.ToString & vbCrLf '& vbCrLf

str &= vbCrLf & tmp '& vbCrLf '& vbCrLf







server_socket.Send(System.Text.Encoding.ASCII.GetBytes(str))

Dim Buffer(1024) As Byte

Dim ByteCount As Int16 = server_socket.Receive(Buffer, Buffer.Length, Net.Sockets.SocketFlags.None)

tmp = System.Text.Encoding.ASCII.GetString(Buffer, 0, ByteCount)

Do While ByteCount > 0

ByteCount = server_socket.Receive(Buffer, Buffer.Length, 0)

tmp2 = (System.Text.Encoding.ASCII.GetString(Buffer, 0, ByteCount))

'If (tmp2.Contains(ststart) = True) Then

' copy = True

'End If

'If (tmp2.Contains(ststop) = True) Then

' ' read &= tmp

' copy = False

'End If

'If copy = True Then

tmp &= tmp2

'End If



Loop

post = tmp

Catch

MsgBox(Err.Description)

post = "ERROR:" & Err.Description

End Try







End Function



Das ergebnis war immer nur der Header...



Public Sub PostPageHTTP() 'ByVal URL As String, ByVal params As ArrayList) As String

Dim wc As New System.Net.WebClient()

Dim t1 As String

t1 = "VARIABLENAUFLISTUNG"

Dim test(t1.Length) As Byte

wc.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1")



wc.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1")

wc.Headers.Add(Net.HttpRequestHeader.Accept, "application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")



wc.UploadStringAsync(New System.Uri("SERVERADRESSE"), t1)





End Sub



So scheint es dann am einfachsten, aber es funktioniert auch nicht, geschweige denn kriege ich eine Seite über irgendeine Funktion zurück...

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: