Code:
Option Explicit
Function Navigate(SCK As Winsock, Url As String, Optional SesId As String = "", Optional Metod As String = "POST", Optional Referer As String = "", Optional POST As String = "")
Dim Host As String
With SCK
.Close
If InStr(1, Url, "//") Then
Host = Split(Url, "/")(2)
Else
Host = Split(Url, "/")(0)
Host = Split(Host, ".", 2)(1)
End If
.Connect Host, "80"
While .State < 7
DoEvents
Wend
If .State = 7 Then
.SendData Metod & " " & Url & " HTTP/1.1" & vbCrLf
.SendData "Host: " & Host & vbCrLf
.SendData "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030430" & vbCrLf
.SendData "Accept: text/html;q=0.9,text/plain;q=0.8" & vbCrLf
If Referer <> "" Then .SendData "Referer: " & Referer & vbCrLf
.SendData "Accept-Language: en-us,en;q=0.7,ja;q=0.3" & vbCrLf
.SendData "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & vbCrLf
.SendData "Keep-Alive: 300" & vbCrLf
.SendData "Proxy-Connection: keep-alive" & vbCrLf
If SesId <> "" Then .SendData "Cookie: PHPSESSID=" & SesId & vbCrLf
If POST <> "" Then
.SendData "Content-Length: " & Len(POST) & vbCrLf
.SendData "Content-Type: application/x-www-form-urlencoded" & vbCrLf & vbCrLf
.SendData POST & vbCrLf
Else
.SendData vbCrLf
End If
If (SesId = "" And POST = "") Then .SendData vbCrLf
End If
End With
End Function
'------
'Then call it like this
Call Navigate(Winsock1, "http://www.domain.com/post.php", "", "POST", "", "parameter1=aa¶meter2=bb")
Quelle: experts-exchange.com