Нужно отправить GET запрос гуглу и получить ответ.
Направьте в правильное русло.
код ниже.
- Код: Выделить всё
#COMPILE EXE
#DIM ALL
#INCLUDE ONCE "Win32API.inc"
%INVALID_SOCKET = &HFFFFFFFF???
%AF_INET = 2
%IPPROTO_TCP = 6
%SOCK_STREAM = 1
%WSADESCRIPTION_LEN = 256
%WSASYS_STATUS_LEN = 128
UNION in_addr
s_addr AS LONG
s AS STRING * 4
END UNION
TYPE WSADATA
wVersion AS WORD
wHighVersion AS WORD
szDescription AS ASCIIZ * %WSADESCRIPTION_LEN + 1
xFiller1 AS STRING * 3
szSystemStatus AS ASCIIZ * %WSASYS_STATUS_LEN + 1
xFiller2 AS STRING * 3
iMaxSockets AS WORD
iMaxUdpDg AS WORD
lpVendorInfo AS ASCIIZ PTR
END TYPE
TYPE HOSTENT
h_name AS ASCIIZ PTR
h_aliases AS ASCIIZ PTR
h_addrtype AS INTEGER
h_length AS INTEGER
h_addr_list AS DWORD PTR
END TYPE
TYPE SOCKADDR_IN
sin_family AS INTEGER
sin_port AS WORD
sin_addr AS LONG
sin_zero AS STRING * 8
END TYPE
DECLARE FUNCTION WSAStartup LIB "ws2_32.dll" ALIAS "WSAStartup" (BYVAL wVR AS WORD, lpWSAD AS WSADATA) AS LONG
DECLARE FUNCTION WSACleanup LIB "ws2_32.dll" ALIAS "WSACleanup" () AS LONG
DECLARE FUNCTION cconnect LIB "ws2_32.dll" ALIAS "connect" (BYVAL s AS DWORD, sname AS sockaddr_in, BYVAL namelen AS LONG) AS LONG
DECLARE FUNCTION socket LIB "ws2_32.dll" ALIAS "socket" (BYVAL af AS LONG, BYVAL s_type AS LONG, BYVAL protocol AS LONG) AS DWORD
DECLARE FUNCTION gethostbyname LIB "ws2_32.dll" ALIAS "gethostbyname" (hname AS ASCIIZ) AS DWORD
DECLARE FUNCTION ssend LIB "ws2_32.dll" ALIAS "send" (BYVAL s AS DWORD, buf AS ANY, BYVAL buflen AS LONG, BYVAL flags AS LONG) AS LONG
DECLARE FUNCTION rrecv LIB "ws2_32.dll" ALIAS "recv" (BYVAL s AS DWORD, buf AS ANY, BYVAL buflen AS LONG, BYVAL flags AS LONG) AS LONG
DECLARE FUNCTION closesocket LIB "ws2_32.dll" ALIAS "closesocket" (BYVAL s AS DWORD) AS LONG
DECLARE FUNCTION htons LIB "ws2_32.dll" ALIAS "htons" (BYVAL hostshort AS WORD) AS WORD
DECLARE FUNCTION inet_addr LIB "ws2_32.dll" ALIAS "inet_addr" (cp AS ASCIIZ) AS DWORD
GLOBAL SocketAddress AS sockaddr_in
FUNCTION SocketInit() AS LONG
DIM wsastruct AS WSADATA
IF WSAStartup(&H101, wsastruct) = 0 THEN
FUNCTION = 1
ELSE
FUNCTION = 0
END IF
END FUNCTION
FUNCTION SocketCleanup() AS LONG
IF WSACleanup = 0 THEN
SocketCleanup = 1
ELSE
SocketCleanup = 0
END IF
END FUNCTION
FUNCTION SendData(BYVAL s AS DWORD, vMessage AS STRING) AS LONG
DIM TheMsg() AS BYTE, sTemp$
'Select Case variant#(vMessage)
' Case 8209 'byte array
' sTemp = vMessage
' TheMsg() = sTemp
' Case 8 'string, if we recieve a string, its assumed we are linemode
' sTemp = vMessage'StrConv(vMessage, vbFromUnicode)
' Case Else
' sTemp = CStr(vMessage)
' sTemp = vMessage'StrConv(vMessage, vbFromUnicode)
'End Select
'TheMsg() = sTemp
'If UBound(TheMsg) > -1 Then
' SendData = ssend(s, TheMsg(0), (UBound(TheMsg) - LBound(TheMsg) + 1), 0)
'End If
SendData = ssend(s, vMessage, LEN(vMessage), 0)
END FUNCTION
FUNCTION PBMAIN () AS LONG
LOCAL sock,result AS LONG
LOCAL query AS STRING
LOCAL clen, clen2 AS LONG
SocketCleanup
IF SocketInit = 0 THEN MSGBOX "ERROR 1": EXIT FUNCTION
IF AntiCaptchaInit = 0 THEN MSGBOX "ERROR 2": EXIT FUNCTION
sock = socket(2, 1, 6)
'sock = socket(%AF_INET, %SOCK_STREAM, 0)
IF sock = %INVALID_SOCKET OR sock = -1 THEN MSGBOX "ERROR 3": EXIT FUNCTION
IF cconnect(sock, SocketAddress, LEN(SocketAddress)) <> 0 THEN MSGBOX "ERROR 4": EXIT FUNCTION
query = "GET / HTTP/1.1" + $CRLF
query = query + "Accept: */*" + $CRLF
query = query + "Content-Type: application/x-www-form-urlencoded" + $CRLF
query = query + "Accept-Language: ru" + $CRLF
query = query + "User-Agent: Opera" + $CRLF
query = query + "Host: google.com" + $CRLF
query = query + "Connection: Keep-Alive" + $CRLF + $CRLF
clen = LEN(query)
clen2 = SendData(sock, query)
IF clen2 <> clen THEN
closesocket sock
MSGBOX "ERROR 5"
EXIT FUNCTION
END IF
'LOCAL buf AS STRING
'rrecv(sock, buf, 256, 0)
'closesocket sock
'msgbox buf
END FUNCTION
FUNCTION AntiCaptchaInit() AS LONG
DIM hostinfo AS HOSTENT
DIM pHostinfo AS LONG
DIM pIPAddress AS LONG
DIM ipAddress AS LONG
pHostinfo = gethostbyname("google.com")
IF pHostinfo = 0 THEN
wsacleanup
FUNCTION = 0
EXIT FUNCTION
END IF
MoveMemory hostinfo, BYVAL pHostinfo, LEN(hostinfo)
IF hostinfo.h_addrtype <> %AF_INET THEN
wsacleanup
FUNCTION = 0
EXIT FUNCTION
END IF
MoveMemory pIPAddress, BYVAL hostinfo.h_addr_list, 4
MoveMemory ipAddress, BYVAL pIPAddress, 4
SocketAddress.sin_addr = ipAddress
SocketAddress.sin_port = htons(80)'&H5000
SocketAddress.sin_family = %AF_INET
FUNCTION = 1
END FUNCTION