现有个网站地址:“http://www.weixindinwei.com.index.php”
打开之后,在表单中输入坐标信息就可以返回经纬度信息如:
     在 LAC    输入:10151,
     在 CellID 输入:3721,
点击提交,返回了经纬度信息,然后利用google地图显示位置;现在需要用这个网站的这个服务,通过输入坐标信息,得到经纬度信息,不需要显示;
现用监控软件监控到了如下结果:大小    方法    结果    类型                        url
-----------------------------------------------------------------------------------------
3458    POST    200     text/html;charset=utf-8     http://www.weixindinwei.com/search.php
查看了浏览器post到服务器的流如下:
-----------------------------------------------------------------------------------
POST /search.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight, */*
Referer: http://www.weixindinwei.com/search.php
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 4399Box.293; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Host: www.weixindinwei.com
Content-Length: 99
Connection: Keep-Alive
Cache-Control: no-cachelati_l=22.62456314161171&longi_l=114.09594655036926&lac=10151&cellid=3721&submit=%E6%9F%A5%E8%AF%A2
从上面的监控流可以看出:只要在url下这样写:
http://www.weixindinwei.com/search.php?lati_l=22.62456314161171&longi_l=114.09594655036926&lac=10151&cellid=3721&submit=%E6%9F%A5%E8%AF%A2
http://www.weixindinwei.com/search.php?lac=10151&cellid=3721&submit=%E6%9F%A5%E8%AF%A2
http://www.weixindinwei.com/search.php?lac=10151&cellid=3721
应该是可以将数据提交到服务器的
以上3个url都试了,不成功!建议:
只要能用浏览器操作,能返回数据,并能在地图上显示,
就一定可以用MFC的CInternetSession类来post(get方式在这里不可以)数据到服务器,
大不了开发个浏览器?如何Post数据到服务器,望高手帮忙解答?????????????????(希望路过的不要顶这个帖子)以下是用MFC的CInternetSession类的get方法获取http://www.weixindinwei.com/search.php这个网页代码
供参考而已:
       

解决方案 »

  1.   


            CInternetSession session;    
            CHttpFile *file = NULL;    
            CString strURL = "http://www.weixindinwei.com/index.php";    
            CString strHtml = "";   //存放网页数据    
       
            try{    
                  file = (CHttpFile*)session.OpenURL(strURL);    
            }catch(CInternetException * m_pException){    
                  file = NULL;    
                  m_pException->m_dwError;    
                  m_pException->Delete();    
                  session.Close();    
                  AfxMessageBox("CInternetException");    
            }
            CString strLine;    
            if(file != NULL){    
                 while(file->ReadString(strLine) != NULL){    
                 strHtml += strLine;    
            }    
            }else{    
                 MessageBox("fail");    
            }    
            session.Close();    
            file->Close();    
            delete file;    
            file = NULL;   
            MessageBox(strHtml);   
            //需要添加afxinet.h头文件
      

  2.   

    伪码:WSADATA wsaData;
    WSAStartup(MAKEWORD(2, 2), &wsaData);SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (sock == INVALID_SOCKET)
    return;SOCKADDR_IN sockAddr;
    sockAddr.sin_family = AF_INET;
    sockAddr.sin_port = htons(59199);
    sockAddr.sin_addr.s_addr = inet_addr("目标地址");if (connect(fd, ....))
    {
        // http请求头,写的不完整,简单表达是这样的,你把你请求的数据填入就行
        char buf[] = "POST /search.php HTTP/1.1\r\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash,\r\n ... ... ... ...";
        ret = send(fd, buf, strlen(buf), 0);
    }
      

  3.   

    我也想知道呀,用GET方法弄得页面还是问题,谁知道怎样用socket函数弄到百度的页面?