我做一个客户端与http服务器连接,记录它的网页内容
我做一个客户端与http服务器连接,记录它的网页内容。
我先是与服务器连接(连上了),
我向服务器发请求信息,
cs->receive(Buffer,READCOUNT);//就停在这里,什么都收不到,
是我的请求信息不对吗?
GET /{0} HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2; .NET CLR 1.1.4322)
Host: {1}
Connection: Keep-Alive
{0} index{2}.htm
{1} 10.126.9.139
{2}rang 1 6
for(int i=rangeS;i<=rangeE;i++){
CppSocket cs(host,80);
cs.connect();
string msgFull,temp;
temp=msg_vector[pos];
ostrstream os;
os<<i;
msgFull=msg_vector[pos].replace(msg_vector[pos].find_first_of("{2}"),3,os.str(),0,os.pcount());
delete os.str();
for(int j=0;j<msg_vector.size();j++){
cs.send(msg_vector[j],msg_vector[j].length());
msg=msg_vector[j];
}
cs.send("\n\n",2);
msg_vector[pos]=temp;
parseRecv(i,&cs);
cs.close();
}
bool parseRecv(int num,CppSocket* cs){
char Buffer[READCOUNT];
::ZeroMemory(Buffer,READCOUNT);
cs->receive(Buffer,READCOUNT);//就停在这里,什么都收不到
string str(Buffer),str1;
int pos,pos2,ch;
str1=str;
for(int i=0;i<str1.length();i++){
ch=(int )str1[i];
if((ch>64)&&(ch<91))
str1[i]=tolower(str1[i]);
}
pos=str1.find("<title>",0);
......
}