|
Познающий
Регистрация: 06.08.2007
Сообщений: 36
Провел на форуме: 373639
Репутация:
10
|
|
Сообщение от Killerkod
Хочется побыстрее и попроще? Напиши свой  В принципе там не трудно, посмотри что De-visible написал... Тоже идея, но все время длина должна быть одинакова, что не есть гуд)) Сделай подругому, чтоб можно было разную длину писать...
Код:
подключить winsock
Function DoRecv(Sock: TSocket): Bool;
Var
Time :TTimeVal;
FD_Struct :TFDSet;
Begin
Result := False;
Time.tv_sec := 5;
Time.tv_usec := 0;
FD_ZERO(FD_Struct);
FD_SET(Sock, FD_Struct);
If Select(0, @FD_Struct, NIL, NIL, @Time) <= 0 Then
Exit;
Result := True;
End;
function pagepost(url,post:string):string;
var
D:WSAData;
S:TSocket;
A:TSockAddr;
name,path:string;
buff:array[0..1023] of char;
buf: Array[0..36000] Of Char;
httpsend,httpresponse,str:string;
recived,n:integer;
begin
httpresponse:='';
{??????? ????????? ????????????...}
if(copy(url,1,7)<>'http://') then
begin
exit;
end;
url:=copy(url,8,length(url));
n:=Pos('/',url);
if(n=0) then
begin
name:=copy(url,1,length(url));
path:='/';
end
else
begin
name:=copy(url,1,n-1);
path:=copy(url,n,length(url));
end;
{????????}
if WSAStartup($101,D)<>0 then
begin
result:='';
WSACleanup;
exit;
end;
A.sin_family:=AF_INET;
A.sin_addr.S_addr:=inet_addr(pChar(NameToIP(name)));
A.sin_port:=htons(80);
S:=socket(AF_INET,SOCK_STREAM,0);
if S=INVALID_SOCKET then
begin
result:='';
WSACleanup;
exit;
end;
if(connect(S,A,sizeof(A))<>0) then
begin
result:='';
WSACleanup;
exit;
end;
// - - - - - - - - - -
// - - - - - - - - - -
{?????????????? ?????}
{?????????? ???????}
httpsend:='POST '+path+' HTTP/1.1'+#13#10+
'Host: '+name+#13#10+
'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; ru; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9'+#13#10+
'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'+#13#10+
'Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3'+#13#10+
'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7'+#13#10+
'Keep-Alive: 300'+#13#10+
'Connection: keep-alive'+#13#10+
'Cookie: remixchk=5'+#13#10+
'Content-Type: application/x-www-form-urlencoded'+#13#10+
'Content-Length: '+inttostr(length(post))+#13#10#13#10+post;
send(s, HTTPSend[1], length(httpsend),0);
recived:=1;
while(recived>0) do
begin
If Not DoRecv(S) Then
Begin
result:=httpresponse;
CloseSocket(S);
WSACleanUp;
Exit;
End;
recived:=Recv(S, Buff, 1024, 0);
HttpResponse:=httpresponse+Copy (Buff,1,Recived);
end;
result:=httpresponse;
closesocket(s);
WSACleanUp;
end;
|