- 论坛徽章:
- 0
|
在VC6.0下 想写一个程序自动登录一个网站
程序如下
#pragma comment(lib,"Ws2_32.lib")
#include <stdio.h>
#include <Winsock2.h>
void main()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
int rest;
char *resp="GET /d**UnReg**/?refurl=®from=&username=123456uid&password1=123456&password2=&email= HTTP/1.1..Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/QVOD, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*..Referer: http://game.cs.js.cn/dgyz/join/..Accept-Language: zh-cn..UA-CPU: x86..Accept-Encoding: gzip, deflate..User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)..Host: game.cs.js.cn..Connection: Keep-Alive\n\n";
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||
HIBYTE( wsaData.wVersion ) != 1 ) {
WSACleanup( );
return;
}
SOCKET sockClient=socket(AF_INET,SOCK_STREAM,0);
SOCKADDR_IN addrSrv;
addrSrv.sin_addr.S_un.S_addr=inet_addr("58.253.67.108");
addrSrv.sin_family=AF_INET;
addrSrv.sin_port=htons(80);
rest=connect(sockClient,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));
if(rest==-1){
printf("errr ");
exit(1);
}
send(sockClient,resp,strlen(resp),0);
char recvBuf[200];
recv(sockClient,recvBuf,200,0);
// printf("3332\n");
printf("%s\n",recvBuf);
closesocket(sockClient);
WSACleanup();
}
可是结果却是 :
HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Thu, 05 Mar 2009 07:00:18 GMT
Connection: close
Content-Length: 20
<h1>Bad Request</h1>
Press any key to continue
不知道是什么原因
是不是要把 cookie 也带上啊 但是实在是不知道怎么带啊
[[i] 本帖最后由 uid500 于 2009-3-5 15:22 编辑 [/i]] |
|